forked from karan/validator.dart
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
strong-mode: | ||
implicit-dynamic: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import 'helpers.dart'; | ||
import 'validator.dart'; | ||
|
||
Map<String, Object> _default_normalize_email_options = {'lowercase': true}; | ||
Map<String, Object> _defaultNormalizeEmailOptions = {'lowercase': true}; | ||
|
||
/// convert the input to a string | ||
String toString(input) { | ||
String toString(Object? input) { | ||
if (input == null || (input is List && input.isEmpty)) { | ||
input = ''; | ||
} | ||
|
@@ -82,25 +82,24 @@ String rtrim(String str, [String? chars]) { | |
/// The characters are used in a RegExp and so you will need to escape | ||
/// some chars. | ||
String whitelist(String str, String chars) { | ||
return str.replaceAll(RegExp('[^' + chars + ']+'), ''); | ||
return str.replaceAll(RegExp('[^$chars]+'), ''); | ||
} | ||
|
||
/// remove characters that appear in the blacklist. | ||
/// | ||
/// The characters are used in a RegExp and so you will need to escape | ||
/// some chars. | ||
String blacklist(String str, String chars) { | ||
return str.replaceAll(RegExp('[' + chars + ']+'), ''); | ||
return str.replaceAll(RegExp('[$chars]+'), ''); | ||
} | ||
|
||
/// remove characters with a numerical value < 32 and 127. | ||
/// | ||
/// If `keep_new_lines` is `true`, newline characters are preserved | ||
/// `(\n and \r, hex 0xA and 0xD)`. | ||
String stripLow(String str, [bool keep_new_lines = false]) { | ||
String chars = keep_new_lines == true | ||
? '\x00-\x09\x0B\x0C\x0E-\x1F\x7F' | ||
: '\x00-\x1F\x7F'; | ||
String stripLow(String str, [bool keepNewLines = false]) { | ||
String chars = | ||
keepNewLines == true ? '\x00-\x09\x0B\x0C\x0E-\x1F\x7F' : '\x00-\x1F\x7F'; | ||
return blacklist(str, chars); | ||
} | ||
|
||
|
@@ -126,7 +125,7 @@ String escape(String str) { | |
/// tags (e.g. `[email protected]` becomes `[email protected]`) and all | ||
/// `@googlemail.com` addresses are normalized to `@gmail.com`. | ||
String normalizeEmail(String email, [Map<String, Object>? options]) { | ||
options = merge(options, _default_normalize_email_options); | ||
options = merge(options, _defaultNormalizeEmailOptions); | ||
if (isEmail(email) == false) { | ||
return ''; | ||
} | ||
|
@@ -142,7 +141,7 @@ String normalizeEmail(String email, [Map<String, Object>? options]) { | |
if (options['lowercase'] == false) { | ||
parts[0] = parts[0].toLowerCase(); | ||
} | ||
parts[0] = parts[0].replaceAll('\.', '').split('+')[0]; | ||
parts[0] = parts[0].replaceAll('.', '').split('+')[0]; | ||
parts[1] = 'gmail.com'; | ||
} | ||
return parts.join('@'); | ||
|
Oops, something went wrong.