Skip to content

Commit

Permalink
fix(@angular/cli): prevent bypassing select/checkbox prompts on valid…
Browse files Browse the repository at this point in the history
…ation failure

Previously, when a select or checkbox prompt failed validation, it was bypassed, preventing users from correcting their input. This commit ensures that when validation fails, the prompts are re-displayed, allowing users to make the necessary corrections. This improves the user experience and helps avoid unintended selections.

Closes #28189
  • Loading branch information
alan-agius4 committed Aug 12, 2024
1 parent ce11a39 commit c5ed0b1
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ export abstract class SchematicsCommandModule
definition.multiselect ? prompts.checkbox : prompts.select
)({
message: definition.message,
validate: (values) => {
if (!definition.validator) {
return true;
}

return definition.validator(Object.values(values).map(({ value }) => value));
},
default: definition.default,
choices: definition.items?.map((item) =>
typeof item == 'string'
Expand Down

0 comments on commit c5ed0b1

Please sign in to comment.