@elsikora/nestjs-crud-automator
Version:
A library for automating the creation of CRUD operations in NestJS.
36 lines (35 loc) • 1.95 kB
TypeScript
import { IMustMatchOneOfSchemasDiscriminatorConfig } from '../interface/validator';
import { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
export declare class MustMatchOneOfSchemasConstraint implements ValidatorConstraintInterface {
private allowedValues;
private discriminatorField;
private discriminatorValue;
private errorType;
/**
* Provides a custom error message based on the type of validation failure
* @param {ValidationArguments} _arguments - Validation arguments containing property information
* @returns {string} A descriptive error message explaining why validation failed
*/
defaultMessage(_arguments: ValidationArguments): string;
/**
* Validates whether an object matches one of the allowed schemas based on its discriminator field
* @param {unknown} value - The value being validated
* @param {ValidationArguments} _arguments - Validation arguments containing constraints
* @returns {boolean} True if the value matches a valid schema, false otherwise
*/
validate(value: unknown, _arguments: ValidationArguments): boolean;
/**
* Prepares the list of allowed discriminator values based on validation constraints
* @param {ValidationArguments} _arguments - Validation arguments containing constraints
* @returns {void}
* @private
*/
private prepareAllowedSchemas;
}
/**
* Decorator that checks if the object matches one of the schemas based on the discriminator field
* @param {IMustMatchOneOfSchemasDiscriminatorConfig} discriminatorConfig - Configuration for the discriminator
* @param {ValidationOptions} [validationOptions] - Validation options
* @returns {PropertyDecorator} - Decorator
*/
export declare function MustMatchOneOfSchemasValidator(discriminatorConfig: IMustMatchOneOfSchemasDiscriminatorConfig, validationOptions?: ValidationOptions): PropertyDecorator;