Skip to content

Documentation / @super-line/core / validate

Function: validate() ​

validate<S>(schema, value): Promise<InferOutput<S>>

Defined in: packages/core/src/contract.ts:463

Validate a value against a Standard Schema validator (sync or async).

Type Parameters ​

S ​

S extends Schema<unknown, unknown>

Parameters ​

schema ​

S

the validator to run.

value ​

unknown

the untrusted value to validate.

Returns ​

Promise<InferOutput<S>>

the parsed, typed value.

Throws ​

SuperLineError with code VALIDATION if the value doesn't match.

Released under the MIT License.