Rule constructor
Rule(
- String? value, {
- required String name,
- Map<
String, String> ? customErrors, - String? customErrorText,
- bool isEmail = false,
- bool isPhone = false,
- bool isIp = false,
- bool isUrl = false,
- bool isRequired = false,
- bool isNumeric = false,
- bool isNumericDecimal = false,
- bool isAlphaSpace = false,
- bool isAlphaNumeric = false,
- bool isAlphaNumericSpace = false,
- RegExp? regex,
- int? length,
- int? minLength,
- int? maxLength,
- double? greaterThan,
- double? greaterThanEqualTo,
- double? lessThan,
- double? lessThanEqualTo,
- double? equalTo,
- double? notEqualTo,
- List<
double> ? equalToInList, - List<
double> ? notEqualToInList, - List<
String> ? inList, - List<
String> ? notInList, - String? shouldMatch,
- String? shouldNotMatch,
- Validator? shouldPass,
- 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();
}