jpa - Acceptance of specific values using Hibernate -
if use annotation @size(min = 1, max = 50)
in hibernate, can write string database @ least 1 , @ 50 characters.
but need restrict possible values 2 numbers: 12342
, 13409
.
is there annotation allows this?
you can use pattern
annotation example:
@pattern(regexp="12342|13409") private string string;
otherwise can write custom constraint.
see documentation further information.
https://docs.jboss.org/hibernate/validator/5.2/reference/en-us/html/validator-customconstraints.html
Comments
Post a Comment