Open
Description
Description
When implementing custom validators and using array of symbols as constraints, an error is raised when the error message is generated for a failed validation.
Minimal code-snippet showcasing the problem
const mySymbol = Symbol('mySymbol');
function IsSameType(property: unknown, validationOptions?: ValidationOptions) {
return function (object: object, propertyName: string): void {
registerDecorator({
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
constraints: [property],
validator: {
validate(value: any, args: ValidationArguments) {
return args.constraints[0].some(t => typeof value === typeof t);
},
defaultMessage: buildMessage(
eachPrefix + '$property must be of type ' + properties.map(property => typeof property).join(' or '),
validationOptions
),
},
});
};
}
class MyClass {
@IsOneOfTypes([mySymbol])
property: symbol;
}
const model = new MyClass();
// this will raise an error when generating the message
validator.validate(model)
Expected behavior
No error should be raised when generating a failed validation message.
Actual behavior
An error is raised when generating a failed validation message.