-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I think that the method 'valid' which allows to specify/ENUMERATE the allowed values should be renamed to enum.
Reasons?
For someone new who hasn't memoired the API yet, 'valid' can be confused with the actual validation, also 'enum' is a term known in many type-safe languages which means exactly this and Mongoose uses it too. Googling joi valid doesn't yield anything related to enumerations, because Google is picking all the mentions of Joi.validate method.
Last, but not least when teaching someone and dictating code it can get confusing-especially for people from foreign countries.
Joi.number().valid('a').validate('a');
Joi.number().enum('a').validate(3); Or just create an alias 'enum'?
I haven't used Joi very extensively yet, but I think there should not be a problem to just deprecate 'valid' and add enum() from next major version.