Announcement Announcement Module
Collapse
No announcement yet.
Validation - email, url, uniqueness Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation - email, url, uniqueness

    Hi,

    what is the best way to add these validations to entity:

    - check if string field is correct email
    - check if string field is correct url
    - check if string field is unique

    ?

    Thanks in advance.

  • #2
    The first two could be resolved by specifyting a JSR-303 annotation @Pattern("") which allows you to define a regular expression to check your String fields.

    The third point could be done by using the JPA @Column(unique=true) annotation. Unfortunately there is no equivalent in the bean validation API so you might have to resort to writing your own if you want it to be picked up during validation.

    HTH,
    Stefan

    Comment

    Working...
    X