Skip to content

std-schema

a small reified Schema<T> validator (M7, MVP).

Types

Validated

type Validated<T> = Valid(T) | Invalid(string)

Outcome of Schema.parse — either Valid(T) or Invalid(message).

Classes

Schema

class Schema<T>

Reified validator with accepts and parse.

Field

class Field

Functions

string

function string(): Schema<string>

Schema that accepts JavaScript strings.

number

function number(): Schema<number>

boolean

function boolean(): Schema<boolean>

array

function array<T>(item: Schema<T>): Schema<T[]>

field

function field(key: string, schema: Schema<dynamic>): Field

object

function object(fields: Field[]): Schema<dynamic>

literal

function literal(expected: string): Schema<string>

optional

function optional<T>(item: Schema<T>): Schema<T?>

nullable

function nullable<T>(item: Schema<T>): Schema<T?>
Documentation