Skip to content

dart_schema_builder/lib/src/formats.dart has bad email regex #291

@RandalSchwartz

Description

@RandalSchwartz

Describe the bug
dart_schema_builder/lib/src/formats.dart has an incorrect regex for email.

To Reproduce
View the source:

'email': (value) {
    return RegExp(
      r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~-]+@[a-zA-Z0-9]+\.[a-zA-Z]+",
    ).hasMatch(value);
  },

Expected behavior
No, please don't use this regex to validate email. It's wrong. The shortest regex to validate an RFC822 email address is about 2400 characters, and is given in https://www.ex-parrot.com/pdw/Mail-RFC822-Address.html. Anything shorter is WRONG, unless you're using a grammar, as package:email_validator properly does. Use that for Dart/Flutter please.

Additional context
Common mistake, because most people don't know the facts about email. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions