Skip to content

Documentation / @super-line/core / validate

Function: validate()

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

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

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

Type Parameters

S

S extends Schema

Parameters

schema

S

the validator to run.

value

unknown

the untrusted value to validate.

Returns

Promise<InferOutput<S>>

the parsed, typed value.

Throws

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

Released under the MIT License.