validata
Version:
Type safe data validation and sanitization
16 lines (15 loc) • 860 B
TypeScript
import { CommonValidationOptions } from './common';
import { ValueProcessor } from './types';
type EnumValue = string | number;
type EnumType = {
[key: string]: EnumValue;
};
interface ValidationOptions<T> extends CommonValidationOptions<T> {
showValidKeys?: boolean;
showValidValues?: boolean;
}
export declare const isEnum: <T extends string | number>(type: EnumType, options?: ValidationOptions<T>) => ValueProcessor<T>;
export declare const maybeEnum: <T extends string | number>(type: EnumType, options?: ValidationOptions<T>) => ValueProcessor<T | undefined>;
export declare const asEnum: <T extends string | number>(type: EnumType, options?: ValidationOptions<T>) => ValueProcessor<T>;
export declare const maybeAsEnum: <T extends string | number>(type: EnumType, options?: ValidationOptions<T>) => ValueProcessor<T | undefined>;
export {};