@Valid annotation


#1

Hello Hibernate Community,

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 ??


#2

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.


#3

Thanks Gasmet, my case is to validate double property, and after search I found I can use typematch.beanName.property Name = please enter valid number

Thanks and Regards,