A schema extending BaseSchema
.
A map of property names to their respective schemas.
This type is used to define the structure of an object schema, where each key corresponds to a property name and the value is a schema that validates the property's value.
The Val
type defines the contract for the val
API, which provides methods for creating and validating schemas.
This API is designed to simplify schema creation and validation for various data types.
Creates an array schema.
Creates a boolean schema.
Provides coercion-based schemas for transforming input data into the desired type.
Creates a boolean schema that coerces input into a boolean before validation.
Creates a date schema that coerces input into a date before validation.
Creates a number schema that coerces input into a number before validation.
Creates a string schema that coerces input into a string before validation.
Creates a date schema.
Creates a schema that validates email addresses.
Creates an enum schema.
Creates a schema that validates ISO date strings.
Creates a number schema.
Creates an object schema.
Creates a string schema.
Creates a schema that validates URLs.
Creates a schema that validates UUIDs.
Generated using TypeDoc
Infers the TypeScript type from a given schema.
This utility type extracts the type that the schema validates, making it easier to work with strongly typed data.
const schema = val.string(); type InferredType = InferSchema<typeof schema>; // InferredType is `string` const numberSchema = val.number(); type NumberType = InferSchema<typeof numberSchema>; // NumberType is `number` const objectSchema = val.object({ name: val.string(), age: val.number(), }); type ObjectType = InferSchema<typeof objectSchema>; // ObjectType is { name: string; age: number }