Skip to content

Commit 05a274a

Browse files
committed
fix(@angular/cli): prevent bypassing select/checkbox 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 fae9542)
1 parent ff5a0fe commit 05a274a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/angular/cli/src/command-builder/schematics-command-module.ts

+7
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ export abstract class SchematicsCommandModule
197197
definition.multiselect ? prompts.checkbox : prompts.select
198198
)({
199199
message: definition.message,
200+
validate: (values) => {
201+
if (!definition.validator) {
202+
return true;
203+
}
204+
205+
return definition.validator(Object.values(values).map(({ value }) => value));
206+
},
200207
default: definition.default,
201208
choices: definition.items?.map((item) =>
202209
typeof item == 'string'

0 commit comments

Comments
 (0)