import { ClassConstructor } from "class-transformer"; import { ValidatorOptions } from "class-validator"; /** * Used to easy validate your data with class validator by passing the validator class and the data to validate, and if whished some validation options * * @param {ClassConstructor} DtoClass - The DTO class you want to use to validate the data * @param {Record} data - The data to validated * @param {ValidatorOptions} validationOptions - class-validator validation options, default {whitelist: true} * @returns {Promise | AppError} - returns the validated data or the encountered errors. * * * @example * ```ts * class CreateUserDto { * @IsString() * name: string; * * @IsEmail() * email: string; * } * * async function main() { * const data = { name: "Uanela Como", email: "invalid-email" }; * try { * const validatedUser = await validateDto(CreateUserDto, data); * // do something * } catch (error) { * console.error(error.message); * } * } * ``` */ export default function validateDto(DtoClass: ClassConstructor, data: Record, validationOptions?: ValidatorOptions): Promise;