We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline with similar requests such as https://github.com/typestack/class-validator/pull/36 In cases where child/nested object requires a parent value for it's validation
I suggest adding root Object to validation function :
export interface ValidatorConstraintInterface { validate(value: any, validationArguments?: ValidationArguments, root ?: any): Promise<boolean> | boolean; defaultMessage?(validationArguments?: ValidationArguments): string; }
It is a relatively simple change on ValidationExecutor that I do not identify and issues with
export class ValidationExecutor { ... private root:any = undefined; ... execute(object: object, targetSchema: string, validationErrors: ValidationError[]): void { ... if(this.root === undefined){ this.root = object; } private customValidations(object: object, value: any, metadatas: ValidationMetadata[], error: ValidationError): void { ... if (!metadata.each || !(Array.isArray(value) || value instanceof Set || value instanceof Map)) { const validatedValue = customConstraintMetadata.instance.validate(value, validationArguments,this.root);... ... const validatedSubValues = arrayValue.map((subValue: any) => customConstraintMetadata.instance.validate(subValue, validationArguments,this.root)
From root object one can find any direct parent, as root contains the validate function ValidationArguments object
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Inline with similar requests such as https://github.com/typestack/class-validator/pull/36
In cases where child/nested object requires a parent value for it's validation
I suggest adding root Object to validation function :
It is a relatively simple change on ValidationExecutor that I do not identify and issues with
From root object one can find any direct parent, as root contains the validate function ValidationArguments object
The text was updated successfully, but these errors were encountered: