@backland/schema
Version:
TypeScript schema declaration and validation library with static type inference
20 lines (19 loc) • 698 B
TypeScript
import { Cast } from '@backland/utils';
import { Infer } from '../Infer';
import { FieldType, FieldTypeParser, TAnyFieldType } from './FieldType';
import { ObjectFieldInput } from './_parseFields';
export type ArrayFieldDef<Of = any> = {
length?: number;
max?: number;
min?: number;
of: Cast<Of, ObjectFieldInput>;
};
export declare class ArrayField<T extends ArrayFieldDef> extends FieldType<Infer<T['of']>[], 'array', T> {
parse: FieldTypeParser<Infer<T>[]>;
utils: {
listItemType: TAnyFieldType;
};
static is(item: any): item is ArrayField<any>;
constructor(def: T);
static create: <T_1 extends ArrayFieldDef<any>>(def: T_1) => ArrayField<T_1>;
}