Rule constructor

Rule(
  1. String? value, {
  2. required String name,
  3. Map<String, String>? customErrors,
  4. String? customErrorText,
  5. bool isEmail = false,
  6. bool isPhone = false,
  7. bool isIp = false,
  8. bool isUrl = false,
  9. bool isRequired = false,
  10. bool isNumeric = false,
  11. bool isNumericDecimal = false,
  12. bool isAlphaSpace = false,
  13. bool isAlphaNumeric = false,
  14. bool isAlphaNumericSpace = false,
  15. RegExp? regex,
  16. int? length,
  17. int? minLength,
  18. int? maxLength,
  19. double? greaterThan,
  20. double? greaterThanEqualTo,
  21. double? lessThan,
  22. double? lessThanEqualTo,
  23. double? equalTo,
  24. double? notEqualTo,
  25. List<double>? equalToInList,
  26. List<double>? notEqualToInList,
  27. List<String>? inList,
  28. List<String>? notInList,
  29. String? shouldMatch,
  30. String? shouldNotMatch,
  31. Validator? shouldPass,
  32. RuleOptions? options,
})

Implementation

Rule(
  this.value, {
  required this.name,
  this.customErrors,
  this.customErrorText,
  this.isEmail = false,
  this.isPhone = false,
  this.isIp = false,
  this.isUrl = false,
  this.isRequired = false,
  this.isNumeric = false,
  this.isNumericDecimal = false,
  this.isAlphaSpace = false,
  this.isAlphaNumeric = false,
  this.isAlphaNumericSpace = false,
  this.regex,
  this.length,
  this.minLength,
  this.maxLength,
  this.greaterThan,
  this.greaterThanEqualTo,
  this.lessThan,
  this.lessThanEqualTo,
  this.equalTo,
  this.notEqualTo,
  this.equalToInList,
  this.notEqualToInList,
  this.inList,
  this.notInList,
  this.shouldMatch,
  this.shouldNotMatch,
  this.shouldPass,
  this.options,
}) {
  // throw an error is 'name' parameter is missing
  if (isNullOrEmpty(name)) {
    throw "Rule => \n'name' parameter is required";
  }

  _applyOptions();
  _run();
}