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