sangamrobo

Validations

Sep 3rd, 2023
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.66 KB | Source Code | 0 0
  1. extension ExtString on String {
  2.   bool get isValidEmail {
  3.     final emailRegExp = RegExp(r"^[a-zA-Z0-9.]+@[a-zA-Z0-9]+\.[a-zA-Z]+");
  4.     return emailRegExp.hasMatch(this);
  5.   }
  6.  
  7.   bool get isValidName {
  8.     final nameRegExp =
  9.         RegExp(r"^\s*([A-Za-z]{1,}([\.,] |[-']| ))+[A-Za-z]+\.?\s*$");
  10.     return nameRegExp.hasMatch(this);
  11.   }
  12.  
  13.   bool get isValidPassword {
  14.     final passwordRegExp = RegExp(
  15.         r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\><*~]).{8,}/pre>');
  16.     return passwordRegExp.hasMatch(this);
  17.   }
  18.  
  19.   bool get isValidPhone {
  20.     final phoneRegExp = RegExp(r"^\+?0[0-9]{10}$");
  21.     return phoneRegExp.hasMatch(this);
  22.   }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment