Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fredeil/email-validator.dart
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.17
Choose a base ref
...
head repository: fredeil/email-validator.dart
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.0
Choose a head ref

Commits on Aug 2, 2022

  1. Copy the full SHA
    588ec80 View commit details

Commits on Aug 15, 2022

  1. Update README.md

    fredeil authored Aug 15, 2022
    Copy the full SHA
    ebd556e View commit details

Commits on Sep 12, 2022

  1. Update README.md

    fredeil authored Sep 12, 2022
    Copy the full SHA
    430f9d0 View commit details

Commits on Oct 11, 2022

  1. Update README.md

    fredeil authored Oct 11, 2022
    Copy the full SHA
    b880344 View commit details

Commits on Oct 19, 2022

  1. Update README.md

    fredeil authored Oct 19, 2022
    Copy the full SHA
    ef0be54 View commit details
  2. Update README.md

    fredeil authored Oct 19, 2022
    Copy the full SHA
    2511698 View commit details
  3. Update README.md

    fredeil authored Oct 19, 2022
    Copy the full SHA
    dbfd03b View commit details

Commits on Nov 9, 2023

  1. Copy the full SHA
    0d4b267 View commit details
  2. Copy the full SHA
    e968709 View commit details
  3. Merge pull request #51 from fredeil/fredeil-patch-1

    Update email_validator.dart
    fredeil authored Nov 9, 2023
    Copy the full SHA
    08b8019 View commit details
  4. Copy the full SHA
    6dd5cab View commit details

Commits on Jun 18, 2024

  1. one letter tld not allowed

    fredeil committed Jun 18, 2024
    Copy the full SHA
    98972bc View commit details

Commits on Jun 21, 2024

  1. Copy the full SHA
    e419225 View commit details
  2. Update pub_publish.yml

    fredeil authored Jun 21, 2024
    Copy the full SHA
    641f2c1 View commit details
  3. Update pub_publish.yml

    fredeil authored Jun 21, 2024
    Copy the full SHA
    4dfd0a3 View commit details
  4. Update pub_publish.yml

    fredeil authored Jun 21, 2024
    Copy the full SHA
    8b8acff View commit details
  5. Update pub_publish.yml

    fredeil authored Jun 21, 2024
    Copy the full SHA
    d932c7d View commit details
  6. Copy the full SHA
    d8111c8 View commit details
  7. Remove outdated stuff

    fredeil committed Jun 21, 2024
    Copy the full SHA
    05fea1e View commit details
  8. Copy the full SHA
    285defd View commit details
  9. update sdk version

    fredeil committed Jun 21, 2024
    Copy the full SHA
    79d7db8 View commit details
Showing with 27 additions and 39 deletions.
  1. +1 −6 .github/workflows/pub_publish.yml
  2. +2 −6 CHANGELOG.md
  3. +16 −3 README.md
  4. +5 −22 lib/email_validator.dart
  5. +2 −2 pubspec.yaml
  6. +1 −0 test/email_validator_test.dart
7 changes: 1 addition & 6 deletions .github/workflows/pub_publish.yml
Original file line number Diff line number Diff line change
@@ -40,9 +40,7 @@ jobs:
if [ ${{ inputs.pre_release }} = "true" ]; then
echo "GIT_TAG=${{ inputs.version }}-dev" | tee -a "$GITHUB_ENV"
fi
- uses: actions/checkout@v3

- name: Update pubspec.yaml
run: sed -i -e 's/^\(\s*version\s*:\s*\).*/\1 ${{ env.GIT_TAG }}/' ${{ env.FILE_PATH }}

@@ -87,7 +85,4 @@ jobs:
tags: true

- name: Publish to pub.dev
run: |
mkdir -p $HOME/.config/dart
echo '${{ secrets.PUB_CREDENTIALS }}' > "$HOME/.config/dart/pub-credentials.json"
dart pub publish -f
run: dart pub publish --force
8 changes: 2 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## 2.1.7
Duplicate type enum found in flutter
## 2.1.16
Bug fixes and performance improvements
## 2.1.15
Bug fixes and performance improvements
## 2.2.9
One letter TLD not allowed

## 2.1.2
Fix static anlyzer warnings and update Dart SDK
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# **Email validator** [![Build status](https://ci.appveyor.com/api/projects/status/fb7ssu5fg8k334vi?svg=true)](https://ci.appveyor.com/project/fredeil/email-validator-dart) [![pub package](https://img.shields.io/pub/v/email_validator.svg)](https://pub.dev/packages/email_validator) [![likes](https://badges.bar/email_validator/likes)](https://pub.dev/packages/email_validator)
# **Email Validator.dart**

A simple (but correct) Dart class for validating email addresses without using RegEx. Can also be used to validate emails within Flutter apps (see [Flutter email validation](https://github.com/fredeil/flutter-email-validator)).
A simple Dart class for validating email addresses without using RegEx. Can also be used to validate emails within Flutter apps (see [Flutter email validation](https://github.com/fredeil/flutter-email-validator)).


**NB:** This library only validates the syntax of the email, not by looking up domain or whether an email actually exists.

**Featured in:**
1. [How To Validate Emails in Flutter](https://betterprogramming.pub/how-to-validate-emails-in-flutter-957ae75926c9) by https://github.com/lucianojung
2. [Flutter Tutorial - Email Validation In 7 Minutes](https://www.youtube.com/watch?v=mXyifVJ-NFc) by https://github.com/JohannesMilke
3. [Flutter Tutorial - Email Validation | Package of the week](https://www.youtube.com/watch?v=ZN_7Pur5h8Q&t=31s) by https://github.com/Dhanraj-FlutterDev

**Found in several big libraries and apps:**

1. [Google Firebase](https://github.com/firebase/flutterfire)
1. [Supabase - Flutter auth UI](https://github.com/supabase-community/flutter-auth-ui)
1. [TubeCards - The world’s best flashcard platform](https://github.com/friebetill/TubeCards)
1. [Serverpod - Serverpod is a next-generation app and web server, explicitly built for Flutter](https://github.com/serverpod/serverpod)
1. [Ventyr.app - An app for last minute experiences - Startup from Tromsø, Norway](https://ventyr.app/)

And many more!


## **Installation**

@@ -16,7 +29,7 @@ Add this to your package's `pubspec.yaml` file:

```yaml
dependencies:
email_validator: '^2.1.16'
email_validator: '^2.1.17'
```
27 changes: 5 additions & 22 deletions lib/email_validator.dart
Original file line number Diff line number Diff line change
@@ -11,42 +11,24 @@ enum SubdomainType { None, Alphabetic, Numeric, AlphaNumeric }
///
/// To use the EmailValidator class, call EmailValidator.methodName
class EmailValidator {
// An atomic index which is reused during iterations in different methods
static int _index = 0;

// A string character set containing all special characters
static const String _atomCharacters = "!#\$%&'*+-/=?^_`{|}~";

// Sets default domainType to null on initialization
static SubdomainType _domainType = SubdomainType.None;

// Returns true if the first letter in string c has a 16-bit UTF-16 code unit
// greater than or equal to 48 and less than or equal to 57
// otherwise return false
static bool _isDigit(String c) {
return c.codeUnitAt(0) >= 48 && c.codeUnitAt(0) <= 57;
}

// Returns true if the first letter in string c has a 16-bit UTF-16 code unit
// greater than or equal to 65 and less than or equal to 90 (capital letters)
// or greater than or equal to 97 and less than or equal to 122 (lowercase letters)
// otherwise return false
static bool _isLetter(String c) {
return (c.codeUnitAt(0) >= 65 && c.codeUnitAt(0) <= 90) ||
(c.codeUnitAt(0) >= 97 && c.codeUnitAt(0) <= 122);
}

// Returns true if calling isLetter or isDigit with the same string returns true
// Only returns false if both isLetter and isDigit return false
static bool _isLetterOrDigit(String c) {
return _isLetter(c) || _isDigit(c);
}

// Returns value of allowInternational if the first letter in the string c isnt a
// number or letter or special character otherwise
// return the result of _isLetterOrDigit or _atomCharacters.contains(c)
// which only returns false if both _isLetterOrDigit and _atomCharacters.contains(c)
// returns false
static bool _isAtom(String c, bool allowInternational) {
return c.codeUnitAt(0) < 128
? _isLetterOrDigit(c) || _atomCharacters.contains(c)
@@ -118,7 +100,6 @@ class EmailValidator {
return false;
}

// TODO: Documentation for this function is required
static bool _skipAtom(String text, bool allowInternational) {
final startIndex = _index;

@@ -145,6 +126,11 @@ class EmailValidator {
_index++;
}

// 1 letter tld is not valid
if (_index == text.length && (_index - startIndex) == 1) {
return false;
}

return (_index - startIndex) < 64 && text[_index - 1] != '-';
}

@@ -246,9 +232,6 @@ class EmailValidator {
return groups == 4;
}

// Returns true if the first letter of the string is
// a,b,c,d,e,f,A,B,C,D,E,F,1,2,3,4,5,6,7,8,9,0
// otherwise, the function returns false
static bool _isHexDigit(String str) {
final c = str.codeUnitAt(0);
return (c >= 65 && c <= 70) ||
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: email_validator
version: 2.1.7
version: 2.2.9

homepage: https://github.com/fredeil/email-validator.dart
description: A simple (but correct) dart class for validating email addresses

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: '>=2.12.0 <4.0.0'

dev_dependencies:
test: ^1.16.8
1 change: 1 addition & 0 deletions test/email_validator_test.dart
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ void main() {
'the-total-length@of-an-entire-address.cannot-be-longer-than-two-hundred-and-fifty-four-characters.and-this-address-is-255-characters-exactly.so-it-should-be-invalid.and-im-going-to-add-some-more-words-here.to-increase-the-lenght-blah-blah-blah-blah-bl.org',
'two..consecutive-dots@sld.com',
'unbracketed-IP@127.0.0.1',
'onelettertld@gmail.c',

// examples of real (invalid) input from real users.
'No longer available.',