Joi Schema
If you need more advanced schema validation gstore-node support Joi types and validator for your properties. Joi is a powerful schema description language with a great API to validate your fields. It it specially useful for complex embedded entities validation or if you need more precision on your validation.
Important: if you decide to use Joi, you have to use it for all your properties. You cannot mix joi and gstore types and validation.
Install
First make sure you have Joi installed
You can define a Joi type and validator by setting a joi setting on your schema property and set the Schema joi option to true.
Joi types can replace all the following settings of a property:
type
validate
default
values
required
But you still need to configure the following settings
excludeFromIndexes
read
write
Advanced
If you need even more control over the schema validation you can define an extra **setting for joi. This will be applied on the complete Joi Schema object type.
Options
The validate() method in Joi accepts an options object. You can pass it in the Schema options.
Last updated