validate static method
Implementation
static bool validate(dynamic value, List<String> validators) {
if (validators.isEmpty) {
return true;
}
for (String validator in validators) {
if (validator == 'nullable') {
if (value == null) {
return true;
}
} else if (validator == 'required') {
if (value == null) {
return false;
}
if (value is String) {
if (value.isEmpty) {
return false;
}
}
} else {
throw Exception(
'Validator not found for: ${validator} with value: ${value}');
}
}
return true;
}