Skip to content

Instantly share code, notes, and snippets.

@edwvilla
Created December 4, 2020 00:41
Show Gist options
  • Save edwvilla/1c66e50f3a456c623a959c15e6ff8968 to your computer and use it in GitHub Desktop.
Save edwvilla/1c66e50f3a456c623a959c15e6ff8968 to your computer and use it in GitHub Desktop.
class AuthValidator {
String validatePassword(String value) {
if (value.length < 6)
return 'Contraseña debe ser mayor a 6 caracteres';
else
return null;
}
String validateEmail(String value) {
const String pattern =
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,}))$';
final RegExp regex = RegExp(pattern);
if (!regex.hasMatch(value))
return 'Ingresa un email valido';
else
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment