Custom validation messages for select-like prompts
Author: aqeelatCreated Jun 3, 2026Updated Jun 3, 2026
Context
This came up while evaluating @clack/prompts as a potential replacement for enquirer.js, comparing it with enquirer.js and @inquirer/prompts.
Split out from: #550
Problem
multiselect has a required option with a built-in validation message:
Please select at least one optionThat 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.'
return true
}Proposal
Add a validate option to select-like prompts, initially multiselect and groupMultiselect:
const selected = await multiselect({
message: 'Choose packages',
options: [...],
validate: (values) => {
if (values.length === 0) return 'Select at least one package.'
return true
},
})The validation function could return true or a string error message.
Notes
This could either replace or complement the current required option.
Source: bombshell-dev/clack