performValidation method
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) {
var name = path ?? 'value';
value = ObjectReader.getValue(value);
super.performValidation(path, value, results);
if (value == null) return;
if (value is List) {
for (var index = 0; index < value.length; index++) {
var elementPath = path != '' && path != null
? path + '.' + index.toString()
: index.toString();
performTypeValidation(
elementPath, getValueType(), value[index], results);
}
} else {
results.add(ValidationResult(
path,
ValidationResultType.Error,
'VALUE_ISNOT_ARRAY',
name + ' type must to be List or Array',
TypeCode.Array,
TypeConverter.toTypeCode(value)));
}
}