ionic-team / ionic-team/ionic-framework

feat: insufficient validation for correct email in IonInput

Đang mở
#30,003 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
triage
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

### 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_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.