[MGNLUI-6547] EmailFieldValidatorFactory does not allow empty fields Created: 02/Feb/21  Updated: 14/Jan/22  Resolved: 14/Jan/22

Status: Closed
Project: Magnolia UI
Component/s: vaadin integration
Affects Version/s: 6.2.5
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Marc Johnen Assignee: Mercedes Iruela
Resolution: Duplicate Votes: 1
Labels: email, validation
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
is duplicated by MGNLUI-6245 Regex field validation has changed fo... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Steps to reproduce 

Create a dialog with:

    optionalMail2:
      label: contact.fields.optionalMail2.label
      $type: textField
      required: false
      validators:
        emailValidator:
          $type: emailValidator
          errorMessage: TestEmailValidator

Expected results

If required is set to false, an empty field should be allowed.

Actual results

EmailValidator always returns an error on empty fields.

Workaround

Use a custom RegexpValidator

Development notes



 Comments   
Comment by Richard Gange [ 03/Feb/21 ]

Vaadin 7 pattern

public EmailValidator(String errorMessage) {
        super("^([a-zA-Z0-9_\\.\\-+])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$",
                true, errorMessage);

Vaadin 8 pattern

private static final String PATTERN = "^" + "([a-zA-Z0-9_\\.\\-+])+" // local
            + "@" + "[a-zA-Z0-9-.]+" // domain
            + "\\." + "[a-zA-Z0-9-]{2,}" // tld
            + "$";
Generated at Mon Feb 12 09:37:35 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.