Advertisement
Guest User

Untitled

a guest
May 20th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.89 KB | None | 0 0
  1. class AmAuditReportIpFilterModel implements AmMultilineInputBaseModel {
  2.   final String _id;
  3.   String get id=>_id;
  4.   String placeholder ='';
  5.  
  6.   final RegExp _regexpIp4 = new RegExp(r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
  7.   final RegExp _regexpCIDR = new RegExp(r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$");
  8.   String value;
  9.   bool isAddNewInput = true;
  10.   bool isActive = true;
  11.   bool isValid = true;
  12.  
  13.   validate(){
  14.     if(quiver.emptyToNull(value)!=null){
  15.       isValid = (_regexpIp4.stringMatch(value) != null) || (_regexpCIDR.stringMatch(value) !=null);
  16.     }
  17.  
  18.     if (value != null && value.isEmpty) {
  19.       isValid = true;
  20.     }
  21.   }
  22.  
  23.   AmAuditReportIpFilterModel(this._id, [this.value]);
  24.  
  25.   String toJson()=>value;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement