Skip to content

Commit

Permalink
fix(@angular-devkit/schematics-cli): prevent bypassing select/checkbo…
Browse files Browse the repository at this point in the history
…x prompts on validation 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

(cherry picked from commit d4e95f2)
  • Loading branch information
alan-agius4 committed Aug 14, 2024
1 parent 05a274a commit 94e27c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/angular_devkit/schematics_cli/bin/schematics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ function _createPromptProvider(): schema.PromptProvider {
)({
message: definition.message,
default: definition.default,
validate: (values) => {
if (!definition.validator) {
return true;
}

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

0 comments on commit 94e27c8

Please sign in to comment.