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
In extension of #938, I'm looking into adding support for the symbol type to Joi to allow something like this:
constenums={first: Symbol('first'),second: Symbol('second')};constschema=Joi.symbol().map(enums);schema.validate('first');// value = Symbol(first)
This will enable eg. an options schema to declare enums using symbols instead of strings.
I could probably create it as an extension, but given that it is a native type (typeof Symbol() === 'symbol'), I'd say that it needs to be a part of the standard package.
How does this sound?
The text was updated successfully, but these errors were encountered:
The enums define a mapping from a string to a Symbol. In this case I have named them similarly, but it doesn't have to be that way.
You could probably also add an option for an implicit map that uses Symbol.for(), along with a pattern.
The primary use-case from my POV, is to parse a configuration. Eg. instead of having to do a string comparison to figure the option, I can test against a Symbol.
In extension of #938, I'm looking into adding support for the
symbol
type to Joi to allow something like this:This will enable eg. an options schema to declare enums using symbols instead of strings.
I could probably create it as an extension, but given that it is a native type (
typeof Symbol() === 'symbol'
), I'd say that it needs to be a part of the standard package.How does this sound?
The text was updated successfully, but these errors were encountered: