ipAddressValidator static method
ipAddressValidator to validate an ip address
validator: (value) => SimpleValidations.ipAddressValidator(value, [errorMessage]),
Implementation
static String? ipAddressValidator(String? value, [String? errorMessage]) {
RegExp regex = CustomRegEx.ipRegex;
if (value == null || value.isEmpty) {
return errorMessage ?? 'Required';
} else if (!regex.hasMatch(value)) {
return errorMessage ?? 'Please enter a valid IP address';
}
return null;
}