Skip to content

Commit

Permalink
fix(ui): validate email with the library instead of the RegExp (#7772)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesnitsky committed Jan 4, 2022
1 parent ae8929d commit b271b7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/flutterfire_ui/lib/src/auth/validators.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/widgets.dart';
import 'package:email_validator/email_validator.dart' as e;

abstract class Validator {
final String errorText;
Expand Down Expand Up @@ -42,15 +43,13 @@ class NotEmpty extends Validator {
}
}

final _emailRegexp = RegExp(r'^[a-zA-Z0-9.]+@[a-zA-Z0-9]+\.[a-zA-Z]+');

class EmailValidator extends Validator {
EmailValidator(String errorText) : super(errorText, []);

@override
String? validate(String? value) {
if (value == null) return errorText;
return _emailRegexp.hasMatch(value) ? null : errorText;
return e.EmailValidator.validate(value) ? null : errorText;
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/flutterfire_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
collection: ^1.15.0
crypto: ^3.0.1
desktop_webview_auth: ^0.0.2
email_validator: ^2.0.1
firebase_auth: ^3.3.4
firebase_core: ^1.10.2
firebase_database: ^9.0.4
Expand Down

0 comments on commit b271b7f

Please sign in to comment.