import type { ValidationOptions } from 'class-validator'; import { IsPhoneNumber as isPhoneNumber, ValidationArguments, ValidatorConstraintInterface } from 'class-validator'; /** * 验证密码格式(只允许字母、数字和特定特殊字符) * * @param validationOptions 验证选项 * * @example * ```typescript * class UserDto { * @IsPassword({ message: 'Invalid password format' }) * password: string; * } * ``` */ export declare function IsPassword(validationOptions?: ValidationOptions): PropertyDecorator; /** * 验证手机号码(支持指定国家/地区) * * @param validationOptions 验证选项,可以指定 region * * @example * ```typescript * class ContactDto { * @IsPhoneNumber({ region: 'CN' }) * phone: string; * } * ``` */ export declare function IsPhoneNumber(validationOptions?: ValidationOptions & { region?: Parameters[0]; }): PropertyDecorator; /** * 验证临时文件路径(必须以 tmp/ 开头) * * @param validationOptions 验证选项 * * @example * ```typescript * class FileDto { * @IsTmpKey() * filePath: string; // 必须是 'tmp/...' * } * ``` */ export declare function IsTmpKey(validationOptions?: ValidationOptions): PropertyDecorator; /** * 允许字段为 undefined,如果不是 undefined 才执行其他验证 * * @param options 验证选项 * * @example * ```typescript * class UserDto { * @IsUndefinable() * @IsString() * nickname?: string; // undefined 或字符串 * } * ``` */ export declare function IsUndefinable(options?: ValidationOptions): PropertyDecorator; /** * 允许字段为空值(null、undefined 或空字符串),如果不为空才执行其他验证 * * @param options 验证选项 * * @example * ```typescript * class UserDto { * @IsEmptyable() * @IsEmail() * email?: string; // 可以为空,或者必须是有效邮箱 * } * ``` */ export declare function IsEmptyable(options?: ValidationOptions): PropertyDecorator; /** * 允许字段为 null,如果不是 null 才执行其他验证 * * @param options 验证选项 * * @example * ```typescript * class UserDto { * @IsNullable() * @IsNumber() * age?: number | null; // null 或数字 * } * ``` */ export declare function IsNullable(options?: ValidationOptions): PropertyDecorator; /** * 验证 HTTP/HTTPS URL * * @param validationOptions 验证选项 * * @example * ```typescript * class WebsiteDto { * @IsHttpUrl({ message: 'Invalid URL' }) * url: string; * } * ``` */ export declare function IsHttpUrl(validationOptions?: ValidationOptions): (object: any, propertyName: string) => void; /** * Validator constraint for AtLeastOneField decorator */ export declare class AtLeastOneFieldConstraint implements ValidatorConstraintInterface { validate(value: any, args: ValidationArguments): boolean; defaultMessage(args: ValidationArguments): string; } /** * 验证至少提供指定字段中的一个 * * @param properties 要检查的属性名数组 * @param validationOptions 验证选项 * * @example * ```typescript * class ContactDto { * @AtLeastOneField(['email', 'phone'], { * message: 'Either email or phone must be provided' * }) * email?: string; * * phone?: string; * } * ``` * * @example * 使用虚拟字段(推荐用于类级别验证): * ```typescript * class ContactDto { * @AtLeastOneField(['email', 'phone']) * _atLeastOne: any; // 虚拟字段用于验证 * * email?: string; * phone?: string; * } * ``` */ export declare function AtLeastOneField(properties: string[], validationOptions?: ValidationOptions): PropertyDecorator;