import Validator from './Validator'; export default class ValidatorRules { private validator; private paramName; /** * Constructor */ constructor(validator: Validator, paramName: string); /** * Ensures the parameter is present and not undefined. */ required(customErrorMessage?: string): this; /** * A placeholder for future validation that may be conditionally applied. */ sometimes(): this; /** * Validates the minimum value or length of the parameter. * Supports strings, numbers, and arrays. */ min(num: number, customErrorMessage?: string): this; /** * Validates the maximum value or length of the parameter. * Supports strings, numbers, and arrays. */ max(num: number, customErrorMessage?: string): this; /** * Ensures the parameter is not null. */ notNullable(customErrorMessage?: string): this; /** * Checks if the parameter value is of type string. */ shouldBeString(customErrorMessage?: string): this; /** * Checks if the parameter value is of type string or null */ shouldBeStringOrNull(customErrorMessage?: string): this; /** * Checks if the parameter value is of type number */ shouldBeNumber(customErrorMessage?: string): this; /** * Checks if the parameter value is of type number or null */ shouldBeNumberOrNull(customErrorMessage?: string): this; /** * Checks if the parameter value is of type boolean. */ shouldBeBoolean(customErrorMessage?: string): this; /** * Checks if the parameter value is of type boolean or null */ shouldBeBooleanOrNull(customErrorMessage?: string): this; /** * Checks if the parameter value is an array. */ shouldBeArray(customErrorMessage?: string): this; /** * Checks if the parameter value is an object (and not null or an array). */ shouldBeObject(customErrorMessage?: string): this; /** * Validates a single nested object using provided validation rules. */ validateObject(validationRules: (validator: Validator) => void): this; /** * Validates each object in an array of objects using provided validation rules. */ validateArrayOfObjects(validationRules: (validator: Validator) => void): this; /** * Validates each value to be a string in an array of strings */ validateArrayOfStrings(customErrorMessage?: string): this; /** * Validates each value to be a string in an array of strings */ validateArrayOfNumbers(customErrorMessage?: string): this; /** * Validates a value to ensure it is a valid email address. * Uses a regular expression to check the format of the value. */ email(customErrorMessage?: string): this; /** * Validates a value to ensure it is a valid email address or null. * Uses a regular expression to check the format of the value. */ emailOrNull(customErrorMessage?: string): this; /** * Validates that the value is within a predefined list of values. */ inList(values: any[], customErrorMessage?: string): this; /** * Validates the value against a custom regular expression pattern. */ regex(pattern: RegExp, customErrorMessage?: string): this; /** * Validates that the value of the current field is different from another field's value. */ different(otherParamName: string, customErrorMessage?: string): this; /** * Validates that the value is one of the enum's values. * Useful for ensuring a value matches one of the predefined options in an enumeration. */ enum(enumObject: object, customErrorMessage?: string): this; /** * Validates that the value is one of the enum's values or null. * Useful for ensuring a value matches one of the predefined options in an enumeration. */ enumOrNull(enumObject: object, customErrorMessage?: string): this; /** * Allows for custom validation logic defined by the user. * The custom function provided should return true if the value passes the validation, * and false otherwise. An optional custom error message can be provided. */ customValidation(validationFunction: (value: any) => boolean, customErrorMessage?: string): this; /** * Merges errors from a child validator into the current validator, optionally with an index for array elements. */ private mergeErrors; /** * Sets an error message in the validator, allowing for an optional custom error message. */ private setError; }