Skip to content

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

Merged
joelittlejohn merged 1 commit into
masterfrom
email-bean-validation
Feb 5, 2023
Merged

joelittlejohn merged 1 commit into
masterfrom
email-bean-validation

Conversation

@joelittlejohn

@joelittlejohn joelittlejohn commented Feb 4, 2023 •

Copy link
Copy Markdown
Owner

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

joelittlejohn commented Feb 4, 2023 •

Copy link
Copy Markdown
Owner Author

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

@unkish unkish left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added few comments

@unkish

unkish commented Feb 5, 2023 •

Copy link
Copy Markdown
Collaborator

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

unkish commented Feb 5, 2023

Copy link
Copy Markdown
Collaborator

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