jet-validators
Version:
Fast, zero-dependency TypeScript validators and utilities for runtime checks, parsing, and lightweight object schema validation.
74 lines (73 loc) • 3.43 kB
JavaScript
import parseObjectCore, { SAFETY, } from './parseObjectCore.js';
export function parseObject(schema, onError) {
return parseObjectCore(false, false, false, schema, SAFETY.Normal, onError);
}
export function parseOptionalObject(schema, onError) {
return parseObjectCore(true, false, false, schema, SAFETY.Normal, onError);
}
export function parseNullableObject(schema, onError) {
return parseObjectCore(false, true, false, schema, SAFETY.Normal, onError);
}
export function parseNullishObject(schema, onError) {
return parseObjectCore(true, true, false, schema, SAFETY.Normal, onError);
}
export function parseObjectArray(schema, onError) {
return parseObjectCore(false, false, true, schema, SAFETY.Normal, onError);
}
export function parseOptionalObjectArray(schema, onError) {
return parseObjectCore(true, false, true, schema, SAFETY.Normal, onError);
}
export function parseNullableObjectArray(schema, onError) {
return parseObjectCore(false, true, true, schema, SAFETY.Normal, onError);
}
export function parseNullishObjectArray(schema, onError) {
return parseObjectCore(true, true, true, schema, SAFETY.Normal, onError);
}
export function strictParseObject(schema, onError) {
return parseObjectCore(false, false, false, schema, SAFETY.Strict, onError);
}
export function strictParseOptionalObject(schema, onError) {
return parseObjectCore(true, false, false, schema, SAFETY.Strict, onError);
}
export function strictParseNullableObject(schema, onError) {
return parseObjectCore(false, true, false, schema, SAFETY.Strict, onError);
}
export function strictParseNullishObject(schema, onError) {
return parseObjectCore(true, true, false, schema, SAFETY.Strict, onError);
}
export function strictParseObjectArray(schema, onError) {
return parseObjectCore(false, false, true, schema, SAFETY.Strict, onError);
}
export function strictParseOptionalObjectArray(schema, onError) {
return parseObjectCore(true, false, true, schema, SAFETY.Strict, onError);
}
export function strictParseNullableObjectArray(schema, onError) {
return parseObjectCore(false, true, true, schema, SAFETY.Strict, onError);
}
export function strictParseNullishObjectArray(schema, onError) {
return parseObjectCore(true, true, true, schema, SAFETY.Strict, onError);
}
export function looseParseObject(schema, onError) {
return parseObjectCore(false, false, false, schema, SAFETY.Loose, onError);
}
export function looseParseOptionalObject(schema, onError) {
return parseObjectCore(true, false, false, schema, SAFETY.Loose, onError);
}
export function looseParseNullableObject(schema, onError) {
return parseObjectCore(false, true, false, schema, SAFETY.Loose, onError);
}
export function looseParseNullishObject(schema, onError) {
return parseObjectCore(true, true, false, schema, SAFETY.Loose, onError);
}
export function looseParseObjectArray(schema, onError) {
return parseObjectCore(false, false, true, schema, SAFETY.Loose, onError);
}
export function looseParseOptionalObjectArray(schema, onError) {
return parseObjectCore(true, false, true, schema, SAFETY.Loose, onError);
}
export function looseParseNullableObjectArray(schema, onError) {
return parseObjectCore(false, true, true, schema, SAFETY.Loose, onError);
}
export function looseParseNullishObjectArray(schema, onError) {
return parseObjectCore(true, true, true, schema, SAFETY.Loose, onError);
}