validate method
- dynamic value,
- String path
override
Validates value at path and returns every violation found.
path is a dot-notation string identifying the location of value
within the document (e.g. 'address.city', '' for the root). Violations
use path as their SchemaViolation.path.
Implementation
@override
List<SchemaViolation> validate(dynamic value, String path) {
// Applies only to arrays; other types are silently skipped.
if (value is! List) return [];
// Pairwise O(n²) deep-equality check. An empty list or single-element
// list is vacuously unique.
for (var i = 0; i < value.length; i++) {
for (var j = i + 1; j < value.length; j++) {
if (_deep.equals(value[i], value[j])) {
return [SchemaViolation(path: path, message: 'items must be unique')];
}
}
}
return [];
}