'Mapping values in json-schema

So JSON schema is defined here and I'm particularly using fluent-json-schema implementation by Fastify team.

I used Joi for validation in an Express app that I'm porting to Fastify.

I use a lot of validation for checkboxes and choice radio inputs. I would like to know how to assign the two boolean values to arbitrary string values

// So this is possible in Joi but not in `fluent-json-schema`
S.boolean().truthy('on').falsy('off').default(false)

Not only for booleans, it would be nice to have the possibility to map values as this is really handy in front and back architectures.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source