SHARE
TWEET

Untitled

a guest Jun 27th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class FormFieldValidator{
  2.   static String validate(String value, String message){
  3.     return (value.isEmpty || (value.contains(**SPECIAL CHARACTERS**))) ? message : null;
  4.   }
  5. }
  6.      
  7. class FormFieldValidator {
  8.   static String validate(String value, String message) {
  9.     return RegExp(r"^[a-zA-Z0-9]+$").hasMatch(value) ? null : message;
  10.   }
  11. }
  12.      
  13. // alphanumeric
  14. static final  validCharacters = RegExp(r'^[a-zA-Z0-9]+$');
  15.      
  16. // alphanumeric and &%=
  17. static final validCharacters = RegExp(r'^[a-zA-Z0-9&%=]+$');
  18.      
  19. // alphanumeric and _-=@,.;
  20. static final validCharacters = RegExp(r'^[a-zA-Z0-9_-=@,.;]+$');
  21.      
  22. validCharacters.hasMatch('abc123');  // true
  23. validCharacters.hasMatch('abc 123'); // false (spaces not allowed)
  24.      
  25. void main() {
  26.   final validCharacters = RegExp(r'^[a-zA-Z0-9_-=@,.;]+$');
  27.   print(validCharacters.hasMatch('abc123'));
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top