java - Hibernate's validateValue() throws illegal argument exception if a property has no rules? -
i have following class:
class foo { @notempty private string member1; @notempty private string member2; private string member3; //this 1 optional, has no rules } i have library add property names , corresponding ui fields, each time ui's onchange event occurs, call validatevalue() on given field name field, validate , show error/success message.
the problem is, in case have no rules member3, if try validate doing this:
string value = event.getvalue(); //whatever new value validator.validatevalue(foo.class, "member3", value); on 2nd line, following exception:
caused by: java.lang.illegalargumentexception: member3 not valid property of com.xxx.foo both member1 , member2 within same class, validated correctly.
is there can avoid getting exception on fields don't have rules set on them? if not, there way (without reflection or specifying manually each field) check if rule has no rules set on it, can avoid calling validatevalue on it?
which version of hibernate validator using? checked latest version (5.1.0.final) , there works. if can recommend upgrade.
you can create issue in validator issue tracker, reporting problem , in particular validator version using.
last not least, answer question alternatives. use bean validation metadata api find constrained properties:
validator.getconstraintsforclass(foo.class).getconstrainedproperties() this allow process properties acually constrained.
Comments
Post a Comment