UNPKG

validata

Version:

Type safe data validation and sanitization

16 lines (15 loc) 1.29 kB
import { CommonConvertOptions, CommonValidationOptions, MaybeOptions, WithDefault } from './common'; import { ValueProcessor } from './types'; interface ItemProcessor { coerceMaxLength?: number; } interface ValidationOptions<I, T extends I[] = I[]> extends CommonValidationOptions<T> { maxLength?: number; minLength?: number; } export type ArrayOptions<I, T extends I[] = I[]> = ItemProcessor & ValidationOptions<I, T>; export declare const isArray: <I, T extends I[] = I[]>(item?: ValueProcessor<I> | undefined, options?: ArrayOptions<I, T> | undefined) => ValueProcessor<T>; export declare const maybeArray: <I, T extends I[] = I[]>(item?: ValueProcessor<I> | undefined, options?: (ItemProcessor & ValidationOptions<I, T> & MaybeOptions) | undefined) => ValueProcessor<T | undefined>; export declare const asArray: <I, T extends I[] = I[]>(item?: ValueProcessor<I> | undefined, options?: (ItemProcessor & ValidationOptions<I, T> & WithDefault<T> & CommonConvertOptions<T>) | undefined) => ValueProcessor<T>; export declare const maybeAsArray: <I, T extends I[] = I[]>(item?: ValueProcessor<I> | undefined, options?: (ItemProcessor & ValidationOptions<I, T> & MaybeOptions & WithDefault<T> & CommonConvertOptions<T>) | undefined) => ValueProcessor<T | undefined>; export {};