computed-types
Version:
Runtime validation types for TypeScript.
18 lines (17 loc) • 1.39 kB
TypeScript
import Validator, { ValidatorProxy } from './Validator';
import FunctionType, { FunctionParameters } from './schema/FunctionType';
import { ErrorLike } from './schema/errors';
import { SchemaParameters, SchemaResolveType, SchemaReturnType } from './schema/io';
import { ResolvedValue } from './schema/utils';
export declare class ArrayValidator<R extends unknown[] | PromiseLike<unknown[]> = unknown[], P extends FunctionParameters = [R]> extends Validator<FunctionType<R, P>> {
of<S>(schema: S, error?: ErrorLike<SchemaParameters<S>>): ValidatorProxy<ArrayValidator<SchemaReturnType<S, SchemaResolveType<S>[]>, P>>;
min(length: number, error?: ErrorLike<[ResolvedValue<R>]>): ValidatorProxy<this>;
max(length: number, error?: ErrorLike<[ResolvedValue<R>]>): ValidatorProxy<this>;
between(minLength: number, maxLength: number, error?: ErrorLike<[ResolvedValue<R>]>): ValidatorProxy<this>;
}
declare const array: {
of<S>(schema: S, error?: ErrorLike<SchemaParameters<S>> | undefined): ValidatorProxy<ArrayValidator<SchemaReturnType<S, SchemaResolveType<S>[]>, [SchemaParameters<S>[0][]]>, FunctionType<SchemaReturnType<S, SchemaResolveType<S>[]>, [SchemaParameters<S>[0][]]>>;
} & Omit<ArrayValidator<unknown[], [unknown[]]>, "validator" | "proxy"> & {
validator: FunctionType<unknown[], [unknown[]]>;
} & FunctionType<unknown[], [unknown[]]>;
export default array;