Skip to content

Schema.array ​

Description ​

Validates that the provided value is an array. Supports enforcing minimum and maximum length constraints.

If the array items should also be validated, use the Schema.list validator instead.

Usage ​

ts
import * as Schema from "@bytelab.studio/schemify";

const schema = Schema.array();

schema.validate([1, 2, 3]);
schema.validate([1, "2", () => {
}]);
schema.validate([]);

Options ​

OptionsTypeDefaultDescription
minLengthnumberundefinedMinimum length of the array.
maxLengthnumberundefinedMaximum length of the array.

Definition ​

ts
export interface ArrayOptions extends RawOptions {
    minLength?: number;
    maxLength?: number;
}

Hierarchy ​