Skip to content

unacy / validateTupleSchema

Function: validateTupleSchema()

ts
function validateTupleSchema(value): value is TupleSchema;

Defined in: packages/core/src/utils/validation.ts:261

Validate that a runtime value is a valid tuple schema.

A valid tuple schema is an array of primitive type name strings, optionally annotated with ? (optional) or ... (rest) modifiers. Empty arrays are accepted.

Parameters

ParameterTypeDescription
valueunknownThe value to validate

Returns

value is TupleSchema

true if value is a valid TupleSchema

Throws

If elements are not strings or contain invalid type names

Example

typescript
validateTupleSchema(['number', 'number', 'number']); // true
validateTupleSchema(['string', 'number?']); // true (optional)
validateTupleSchema(['number', '...string']); // true (rest)

Released under the MIT License.