Skip to main content

schemas

Index

Functions

array

  • Create a schema that validates a value is an array, and optionally validate its items.


    Type parameters

    • T = unknown

blueprint

  • Create a schema that validates a value is an indexed object of schemas.

bool

  • Create a schema that validates a value is a boolean.

custom

  • Create a schema that validates a value based on a defined custom validator callback.


    Type parameters

    • T

date

  • Create a schema that validates a value is a date. Supports Date objects, an ISO-8601 string, or a UNIX timestamp

func

id

  • Create a schema that validates a value is an auto-incrementing ID.

instance

  • Create a schema that validates a value is an instance of a class.


    Type parameters

    • T = Object

lazy

  • Create a schema that defers evaluation of the schema until it’s needed. This is useful for recursive schemas.


    Type parameters

    • T

number

  • Create a schema that validates a value is a number.


    Type parameters

    • T: number

object

  • Create a schema that validates a value is an indexed object (implicit keys).


    Type parameters

    • V = unknown
    • K: PropertyKey = string

constrecord

  • Create a schema that validates a value is an indexed object (implicit keys).


    Type parameters

    • V = unknown
    • K: PropertyKey = string

regex

  • Create a schema that validates a value is a regex pattern (instance of RegExp).

schema

  • Create a schema that validates a value is a schema instance.


    Type parameters

shape

  • Create a schema that validates a value is a shaped object (explicit keys).


    Type parameters

    • T: object

string

  • Create a schema that validates a value is a string.


    Type parameters

    • T: string = string

tuple

  • Create a schema that validates a value is a tuple; an explicit list of types.


    Type parameters

    • T: unknown[] = unknown[]

union

  • Create a schema that validates a value against a list of possible values.


    Type parameters

    • T = unknown

uuid

  • Create a schema that validates a value is a UUID (universally unique identifier).