Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Email bean validation annotation for "format":"email" #1475

Merged
merged 1 commit into from
Feb 5, 2023

Conversation

joelittlejohn
Copy link
Owner

@joelittlejohn joelittlejohn commented Feb 4, 2023

Things to consider if are using the includeJsr303Annotations feature:

  • If you have useJakartaValidation turned on, you'll now see jakarta.validation.constraints.Email added to a property when using "format":"email".
  • If don't have useJakartaValidation turned on, you'll now see javax.validation.constraints.Email added to a property when using "format":"email".
    • The Email annotation is introduced in the bean validation spec 2.0, so you will need to upgrade to javax.validation:validation-api 2.x (2.0.1.Final is a good choice). Note, all old annoations are maintained (with the same fully-qualified name) so upgrading this should not break anything.
    • If email validation is still not happening, your validator might only be doing bean validation 1.0 or 1.1 validations. You would then need to upgrade your validator (e.g. with bval, upgrade to 2.0.5 or later).

@joelittlejohn joelittlejohn added this to the 1.1.4 milestone Feb 4, 2023
@joelittlejohn
Copy link
Owner Author

joelittlejohn commented Feb 4, 2023

If you receive compilation errors because javax.validation.constraints.Email cannot be found, upgrade to javax.validation/validation-api 2.0.1.Final.

Copy link
Collaborator

@unkish unkish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few comments

@unkish
Copy link
Collaborator

unkish commented Feb 5, 2023

If you receive compilation errors because javax.validation.constraints.Email cannot be found, upgrade to javax.validation/validation-api 2.0.1.Final.

Note that given annotation can't be used when targetVersion is less that 1.8 as it has:

  • @Retention(RUNTIME)
  • @Target contains TYPE_USE which is available since 1.8

Those who target older version might also need to make sure that version of javax.validation/validation-api being used is compatible with targetVersion

@joelittlejohn joelittlejohn merged commit 09dd768 into master Feb 5, 2023
@joelittlejohn joelittlejohn deleted the email-bean-validation branch February 5, 2023 13:33
@unkish
Copy link
Collaborator

unkish commented Feb 5, 2023

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants