Skip to content

feat: insufficient validation for correct email in IonInput #30003

@workfluo

Description

@workfluo

Prerequisites

Describe the Feature Request

A validator for email that better checks if an email corresponds to basic requirements for an email.

Describe the Use Case

Currently is considered correct by the IonInput validator for email:
[alphanumeric chars]@[alphanumeric chars] (like 1@1 or a@a or a1@1a)
[alphanumeric chars]@[alphanumeric chars].oneAlphanumericChars (like [email protected] or [email protected]).

But an email must be based on a domain name which means it should end with a dot and a top-level domains (like .com, .tv, .berlin).

So to be validated an email should have:

  1. a dot after the sequence [alphanumeric chars]@[alphanumeric chars]
  2. then more than one alpha chars AND no numbers (TLDs haven't any numbers)

Describe Preferred Solution

There is actually a norm than define correct email: https://www.rfc-editor.org/rfc/rfc2822#section-3.4.1 .
2 Regex can help:

  • the simple one: /[^\s@]+@[^\s@]+.[^\s@]+/
  • the "RFC 2822: /(?:[a-z0-9+!#$%&'+/=?^_{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])")@(?:(?:a-z0-9?.)+a-z0-9?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-][a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\[\x01-\x09\x0b\x0c\x0e-\x7f])+)])/i

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions