truefit/standard
Every export of truefit/standard, with its signature and doc comment: standard, standardAsync, VENDOR, plus 5 types.
import { standard, standardAsync, VENDOR } from 'truefit/standard';Constants
standard
The schema as a Standard Schema: standard(Order)['~standard'].validate(value) is
{ value } or { issues }, from one call of parse. The result is still a schema of this
library: check, issues and parse read it as they read the one it was made from.
const standard: <T, O>(schema: Schema<T, O>) => Standard<T, O>;standardAsync
The same for a schema with a rule or a map to await: validate answers with a promise, from one call of parseAsync.
const standardAsync: <T, O>(schema: Schema<T, O>) => StandardAsync<T, O>;VENDOR
The name this library gives itself in Standard Schema's ~standard.vendor. The package's public
name is not chosen yet (it is a working name), so this is the one place that has to change when it is.
const VENDOR = "validator";Interfaces
StandardIssue
Standard Schema (standardschema.dev, version 1): the ~standard member a library reads to
validate with a schema it did not make. On a subpath of its own, as a wrapper: a node does not
carry the member, so a schema that is never handed to such a library pays nothing for it.
interface StandardIssue {
readonly message: string;
/** The keys from the root to the value at fault: an index into an array is a number. */
readonly path: readonly (string | number)[];
}StandardProps
interface StandardProps<I, O, R> {
readonly version: 1;
readonly vendor: string;
readonly validate: (value: unknown) => R;
/** The input and the output type, for a library to infer from. There is no such value: it is `undefined`. */
readonly types?: {
readonly input: I;
readonly output: O;
} | undefined;
}Types
Standard
A schema of this library that is also a Standard Schema, validating at once.
type Standard<T, O> = Schema<T, O> & {
readonly '~standard': StandardProps<T, Out<T, O>, StandardResult<Out<T, O>>>;
};StandardAsync
The same, validating with a promise.
type StandardAsync<T, O> = Schema<T, O> & {
readonly '~standard': StandardProps<T, Out<T, O>, Promise<StandardResult<Out<T, O>>>>;
};StandardResult
type StandardResult<O> = {
readonly value: O;
readonly issues?: undefined;
} | {
readonly issues: readonly StandardIssue[];
};truefit/json-schema
Every export of truefit/json-schema, with its signature and doc comment: standardJson, toJsonSchema, fromJsonSchema, jsonSchemaReader, plus 13 types.
FAQ
Short answers about truefit: whether it is a drop-in for zod, CommonJS, why check does not coerce, optional at the root, string length, unknown keys, error translation, eval, bundle size and the Standard Schema vendor name, each with where to read more.