mirror of
https://github.com/go-vikunja/app
synced 2024-06-02 18:49:47 +00:00
tweak validator.dart to avoid regex calls if null
This commit is contained in:
parent
3f7dfb276a
commit
a7be6abd0d
|
@ -2,12 +2,14 @@ final RegExp _emailRegex = new RegExp(
|
|||
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$');
|
||||
|
||||
bool isEmail(String? email) {
|
||||
return _emailRegex.hasMatch(email ?? '');
|
||||
if (email == null) return false;
|
||||
return _emailRegex.hasMatch(email);
|
||||
}
|
||||
|
||||
final RegExp _url = new RegExp(
|
||||
r'https?:\/\/((([a-zA-Z0-9.\-\_]+)\.[a-zA-Z]+)|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(:[0-9]+)?');
|
||||
|
||||
bool isUrl(String? url) {
|
||||
return _url.hasMatch(url ?? '');
|
||||
if (url == null) return false;
|
||||
return _url.hasMatch(url);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user