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/chapter-bean-constraints.html#section-builtin-constraints

https://docs.jboss.org/hibernate/validator/5.2/reference/en-us/html/validator-customconstraints.html


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -