export type TValidatorType = "string" | "number" | "boolean" | "date" | "array" | "object" | "email" | "phone"; export interface IStructureOptions { optional?: boolean; skip_validation?: boolean; default?: any; values?: any; regex?: string; min?: number; max?: number; details?: string; type?: string; ignore_in_documentation?: boolean; } export interface IValidatorOptions { min?: number; max?: number; type?: TValidatorType; regex?: RegExp; } export interface IValidaotrType { name: string; type: TValidatorType; optional?: boolean; arrayType?: IValidaotrType; } export declare enum ValidationReport { OK = 1, VALUE_IS_NULL = 2, TYPE_MISSMATCH = 3, VALUE_TOO_BIG = 4, VALUE_TOO_SHORT = 5, VALUE_INCORRECT = 6 } type WidenLiteral = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T; type WidenLiterals = { [K in keyof T]: T[K] extends readonly (infer R)[] ? readonly WidenLiteral[] : T[K] extends (infer R)[] ? WidenLiteral[] : T[K] extends object ? WidenLiterals : WidenLiteral; }; type DeepMutable = T extends ReadonlyArray ? DeepMutable[] : T extends Array ? DeepMutable[] : T extends (...args: any[]) => any ? T : T extends object ? { -readonly [K in keyof T]: DeepMutable; } : T; type IsNever = [T] extends [never] ? true : false; type Or = A extends true ? true : (B extends true ? true : false); type CleanFields = WidenLiterals<{ [K in keyof T as K extends `$__${string}` ? never : K]: T[K]; }>; type HasOptional = Or<`$__${K}_optional` extends keyof T ? T[`$__${K}_optional`] extends true ? true : false : false, `$__${K}` extends keyof T ? T[`$__${K}`] extends { optional: true; } ? true : false : false>; type ExtractOptionalFieldNames = { [K in (keyof T & string) as HasOptional extends true ? K : never]: true; }; type OptionalFields = keyof ExtractOptionalFieldNames & string; type ValuesArr = `$__${K}_values` extends keyof T ? T[`$__${K}_values`] extends readonly (infer V)[] ? readonly V[] : T[`$__${K}_values`] extends (infer V)[] ? readonly V[] : T[`$__${K}_values`] extends Record ? readonly V[] : never : `$__${K}` extends keyof T ? T[`$__${K}`] extends { values: readonly (infer V)[]; } ? readonly V[] : T[`$__${K}`] extends { values: (infer V)[]; } ? readonly V[] : T[`$__${K}`] extends { values: Record; } ? readonly V[] : never : never; type ExtractEnumValues = { [K in (keyof T & string) as IsNever> extends true ? never : K]: ValuesArr extends ReadonlyArray ? V : never; }; type EnumFieldNames = keyof ExtractEnumValues & string; type EnumFieldValues = ExtractEnumValues; type FieldOriginal = K extends keyof T ? T[K] : never; type ProcessValue> = FieldOriginal extends ReadonlyArray ? Item extends object ? ValidationModel[] : WidenLiteral[] : FieldOriginal extends Array ? Item extends object ? ValidationModel[] : WidenLiteral[] : FieldOriginal extends (...a: any[]) => any ? FieldOriginal : FieldOriginal extends object ? ValidationModel> : WidenLiteral>; export type ValidationModel = DeepMutable<{ [K in keyof CleanFields as K extends OptionalFields ? K : never]?: K extends EnumFieldNames ? EnumFieldValues[K] : ProcessValue; } & { [K in keyof CleanFields as K extends OptionalFields ? never : K]: K extends EnumFieldNames ? EnumFieldValues[K] : ProcessValue; }>; export declare class Validator { static validateObject(fields: string[], object: any): boolean; static documentStructure(structure: any): Record | undefined; static parseStructureOptions(key: string, structure: Record): IStructureOptions; static validateStructure(structure: any, object: any, level?: number, parentPath?: string): Promise; static filterStructure(structure: any, object: any): void; static isPlainObject(v: any): boolean; static clone(v: T): T; static syncStructure(structure: any, node: any): any; static convertToType(value: any, type: "string" | "number" | "boolean" | "date"): T | null; static validateValue(value: string | number | boolean, opt?: IValidatorOptions): ValidationReport; } export {};