validate method
void
validate(
- String? path,
- Schema schema,
- dynamic value,
- List<
ValidationResult> results,
override
Validates a given value against this rule.
- path a dot notation path to the value.
- schema a schema this rule is called from
- value a value to be validated.
- results a list with validation results to add new results.
Implementation
@override
void validate(String? path, Schema schema, dynamic value,
List<ValidationResult> results) {
var name = path ?? 'value';
var found = <String>[];
for (var i = 0; i < _properties.length; i++) {
var propertyValue = ObjectReader.getProperty(value, _properties[i]);
if (propertyValue != null) found.add(_properties[i]);
}
if (found.isEmpty) {
results.add(ValidationResult(
path,
ValidationResultType.Error,
'VALUE_NULL',
name +
' must have at least one property from ' +
_properties.join(','),
_properties,
null));
}
}