Skip to content

Commit 5b5b40e

Browse files
authored
Merge pull request #45 from fredeil/type-enum
Type -> SubdomainType
2 parents 79ca309 + 83a189e commit 5b5b40e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/email_validator.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'dart:core';
55
/// The Type enum
66
///
77
/// The domain type is either None, Alphabetic, Numeric or AlphaNumeric
8-
enum Type { None, Alphabetic, Numeric, AlphaNumeric }
8+
enum SubdomainType { None, Alphabetic, Numeric, AlphaNumeric }
99

1010
///The EmailValidator entry point
1111
///
@@ -18,7 +18,7 @@ class EmailValidator {
1818
static const String _atomCharacters = "!#\$%&'*+-/=?^_`{|}~";
1919

2020
// Sets default domainType to null on initialization
21-
static Type _domainType = Type.None;
21+
static SubdomainType _domainType = SubdomainType.None;
2222

2323
// Returns true if the first letter in string c has a 16-bit UTF-16 code unit
2424
// greater than or equal to 48 and less than or equal to 57
@@ -69,20 +69,20 @@ class EmailValidator {
6969
static bool _isDomain(String c, bool allowInternational) {
7070
if (c.codeUnitAt(0) < 128) {
7171
if (_isLetter(c) || c == '-') {
72-
_domainType = Type.Alphabetic;
72+
_domainType = SubdomainType.Alphabetic;
7373
return true;
7474
}
7575

7676
if (_isDigit(c)) {
77-
_domainType = Type.Numeric;
77+
_domainType = SubdomainType.Numeric;
7878
return true;
7979
}
8080

8181
return false;
8282
}
8383

8484
if (allowInternational) {
85-
_domainType = Type.Alphabetic;
85+
_domainType = SubdomainType.Alphabetic;
8686
return true;
8787
}
8888

@@ -94,26 +94,26 @@ class EmailValidator {
9494
static bool _isDomainStart(String c, bool allowInternational) {
9595
if (c.codeUnitAt(0) < 128) {
9696
if (_isLetter(c)) {
97-
_domainType = Type.Alphabetic;
97+
_domainType = SubdomainType.Alphabetic;
9898
return true;
9999
}
100100

101101
if (_isDigit(c)) {
102-
_domainType = Type.Numeric;
102+
_domainType = SubdomainType.Numeric;
103103
return true;
104104
}
105105

106-
_domainType = Type.None;
106+
_domainType = SubdomainType.None;
107107

108108
return false;
109109
}
110110

111111
if (allowInternational) {
112-
_domainType = Type.Alphabetic;
112+
_domainType = SubdomainType.Alphabetic;
113113
return true;
114114
}
115115

116-
_domainType = Type.None;
116+
_domainType = SubdomainType.None;
117117

118118
return false;
119119
}
@@ -174,7 +174,7 @@ class EmailValidator {
174174

175175
// Note: by allowing AlphaNumeric,
176176
// we get away with not having to support punycode.
177-
if (_domainType == Type.Numeric) {
177+
if (_domainType == SubdomainType.Numeric) {
178178
return false;
179179
}
180180

0 commit comments

Comments
 (0)