Files
typebox/docs/types/options.md

900 B

Home | Installation | Usage | Types | Values | Syntax | TypeRegistry | TypeCheck

Options

You can pass Json Schema options on the last argument of any given type. Option hints specific to each type are provided for convenience.

// String must be an email
const T = Type.String({
  // const T = {
  format: "email", //   type: 'string',
}); //   format: 'email'
// }

// Number must be a multiple of 2
const T = Type.Number({
  // const T = {
  multipleOf: 2, //  type: 'number',
}); //  multipleOf: 2
// }

// Array must have at least 5 integer values
const T = Type.Array(Type.Integer(), {
  // const T = {
  minItems: 5, //   type: 'array',
}); //   minItems: 5,
//   items: {
//     type: 'integer'
//   }
// }

Back to Home