import { Context, ValidationRuleObject } from "fastest-validator"; import { ObjectId } from "bson"; //#region src/interfaces/validationSchema.d.ts type RuleType = "any" | "boolean" | "number" | "email" | "object" | "string" | "enum" | "uuid" | "array" | "forbidden" | "function" | "date" | "customDate" | "objectId" | "version" | "phoneNumber" | "internationalPhoneNumber" | "buffer" | "record"; interface CheckerFunctionError { type: string; messages: string; field?: string; } interface BasicRule { type: T; optional?: boolean; default?: unknown; null?: boolean; } interface Sanitazible { convert?: boolean; } interface NumberRule extends BasicRule<"number">, Sanitazible { min?: number; max?: number; equal?: number; notEqual?: number; integer?: boolean; positive?: boolean; negative?: boolean; } interface ArrayRule extends BasicRule<"array"> { items?: ValidationProperty; empty?: boolean; min?: number; max?: number; length?: number; contains?: any; enum?: any[]; unique?: boolean; } interface ObjectRule extends BasicRule<"object"> { props?: ValidationSchema$1; strict?: boolean; } interface RecordRule extends BasicRule<"record"> { key: EnumRule | StringRule; value: ValidationProperty | ValidationProperty[]; } interface StringRule extends BasicRule<"string"> { empty?: boolean; min?: number; max?: number; length?: number; pattern?: any; contains?: any; enum?: string[]; alpha?: boolean; numeric?: boolean; alphanum?: boolean; alphadash?: boolean; uppercase?: boolean; custom?: (value: string, errors: CheckerFunctionError[], ruleSchema?: ValidationRuleObject, path?: string, parent?: object | null, context?: Context) => string; } interface EmailRule extends BasicRule<"email"> { mode?: string; } interface VersionRule extends BasicRule<"version">, Sanitazible { versions?: string[]; } interface EnumRule extends BasicRule<"enum"> { values: T[]; } interface DateRule extends BasicRule<"date">, Sanitazible { format?: string; } interface ListValidationSchema { skip: NumberRule; limit: NumberRule; } interface CustomDateRule extends BasicRule<"customDate">, Sanitazible {} interface ObjectIdRule extends BasicRule<"objectId">, Sanitazible {} interface BooleanRule extends BasicRule<"boolean">, Sanitazible {} type CommonRule = BasicRule<"any" | "forbidden"> | EnumRule; type ComplexRule = StringRule | NumberRule | BooleanRule | ArrayRule | ObjectRule | DateRule | CustomDateRule | EmailRule | EnumRule | ObjectIdRule | RecordRule | VersionRule; type ValidationProperty = T extends null ? ValidationRule : T extends string ? StringRule | EmailRule | VersionRule | BasicRule<"uuid" | "phoneNumber" | "internationalPhoneNumber"> : T extends number ? NumberRule : T extends boolean ? BooleanRule : T extends Date ? DateRule | CustomDateRule | StringRule : T extends Buffer ? BasicRule<"buffer"> : T extends ObjectId ? ObjectIdRule | StringRule : T extends ArrayLike ? ArrayRule : T extends object ? ObjectRule | RecordRule[keyof T]> : ValidationRule; type Rule = string | boolean | ComplexRule | CommonRule | BasicRule>; type ValidationRule = T extends null ? Rule : T extends object ? ObjectRule : T extends ArrayLike ? ArrayRule : Rule; type ValidationSchema$1 = T extends null ? { [path: string]: ValidationRule | ValidationRule[]; } : { [path in keyof Required]: ValidationProperty | ValidationProperty[] | CommonRule }; //#endregion export { ArrayRule, BooleanRule, CheckerFunctionError, CustomDateRule, DateRule, EmailRule, EnumRule, ListValidationSchema, NumberRule, ObjectIdRule, ObjectRule, RecordRule, RuleType, StringRule, ValidationRule, ValidationSchema$1 as ValidationSchema, VersionRule };