performValidation method
void
performValidation()
inherited
Validates a given value against the schema and configured validation rules.
path
a dot notation path to the value.value
a value to be validated.results
a list with validation results to add new results.
Implementation
@override
void performValidation(
String? path, dynamic value, List<ValidationResult> results) {
super.performValidation(path, value, results);
if (value == null) return;
var name = path ?? 'value';
var properties = ObjectReader.getProperties(value);
if (_properties != null) {
for (var i = 0; i < _properties!.length; i++) {
var propertySchema = _properties![i];
var processedName;
for (var key in properties.keys) {
var propertyName = key;
var propertyValue = properties[key];
if (ObjectComparator.areEqual(
propertySchema.getName(), propertyName)) {
propertySchema.performValidation(path, propertyValue, results);
processedName = propertyName;
break;
}
}
if (processedName != null) {
properties.remove(processedName);
} else {
propertySchema.performValidation(path, null, results);
}
}
}
if (_allowUndefined == null || _allowUndefined == false) {
for (var key in properties.keys) {
var propertyPath = path != null && path != '' ? path + '.' + key : key;
results.add(ValidationResult(
propertyPath,
ValidationResultType.Warning,
'UNEXPECTED_PROPERTY',
name + ' contains unexpected property ' + key,
null,
key));
}
}
}