ionic-team / ionic-team/ionic-framework

feat: insufficient validation for correct email in IonInput

Offen
#30,003 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
triage
Vorherrschende Sprache
TypeScript
Sterne
52.7k
Forks
13.3k
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
51

Beschreibung

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.

### 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 1@1.a or a@1.1).

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-]*[a-z0-9])?\.)+[a-z0-9](?:[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_

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.