Skip to content

Add Symbol() support #1420

@kanongil

Description

@kanongil

In extension of #938, I'm looking into adding support for the symbol type to Joi to allow something like this:

const enums = {
    first: Symbol('first'),
    second: Symbol('second')
};
const schema = 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?

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions