You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom validation messages for select-like prompts #553
multiselect has a required option with a built-in validation message:
Please select at least one option
That message is not customizable, and there is no general validation hook for select-like prompts.
In enquirer.js, this kind of validation can be customized:
validate(value){if(value.length===0)return'You must choose at least one package.'returntrue}
Proposal
Add a validate option to select-like prompts, initially multiselect and groupMultiselect:
constselected=awaitmultiselect({message: 'Choose packages',options: [...],validate: (values)=>{if(values.length===0)return'Select at least one package.'returntrue},})
The validation function could return true or a string error message.
Notes
This could either replace or complement the current required option.
Activity