Types

  • String

      someField:  Joi.string()
  • Unique string

      someField: Joi.string()[required]().meta({unique: true}),
  • String with enums

      someField: Joi.string().valid('private', 'public','blocked'),
  • Number

      someField:  Joi.number()
  • Pointer

    someField: Joi.objectId().meta({
                type: 'ObjectId',
                ref: 'users',
                displayKey: 'email'
              }),
  • Date

      someField:  Joi.date()
  • Boolean

      someField:  Joi.boolean()
  • Arrays

      someField:  Joi.array()
  • Arrays of String

      someField:  Joi.array().items(Joi.string())
  • Arrays of Reference

      someField:  Joi.array().items(Joi.string().meta({ type: 'ObjectId', ref: 'rules', displayKey: 'name' })),
  • Object

      someField:  Joi.object({
         user: Joi.objectId().meta({
          type: 'ObjectId',
          ref: 'users',
          displayKey: 'email'
        }),
         rules: Joi.array().items(Joi.string().meta({ type: 'ObjectId', ref: 'users', displayKey: 'name'})),
         blockAll: Joi.boolean()
         })

Allow null?

verifyExpires: Joi.date().allow(null)

Default Value?

status: Joi.string().meta({ default: 'pending'})

Last updated