I just ask why @Valid annotation doesn’t has message attribute @Valid(message=“Error in number you enter”) as a general validator, also we can config it in properties file like:
class Employee{ @Valid
private double age;
}
Valid.employee.age = Enter valid number
it is not work because there is no message attribute in @Valid annotation
so I wait your opinion or may be i miss something ??
The @Valid annotation is used for cascading i.e. when you want to cascade the validation to another bean.
I think you’re trying to use it as a constraint and that’s not what it is used for. Just add constraints to your properties and they will be validated.