-
-
Save boeledi/d1bdc8ca236a9521b6a10fdb96595ee4 to your computer and use it in GitHub Desktop.
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
const String _kEmailRule = r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"; | |
class EmailValidator { | |
final StreamTransformer<String,String> validateEmail = | |
StreamTransformer<String,String>.fromHandlers(handleData: (email, sink){ | |
final RegExp emailExp = RegExp(_kEmailRule); | |
if (!emailExp.hasMatch(email) || email.isEmpty){ | |
sink.addError('Entre a valid email'); | |
} else { | |
sink.add(email); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment