}
};
}
if (_minimumItems != null && coll.size() < _minimumItems) {
results.addResult(new ValidationResult().type(ResultType.CONSTRAINT_VIOLATION).path(path).message("Array does not have enough items, < " + _minimumItems + ": " + coll));
}
if (_maximumItems != null && coll.size() > _maximumItems) {
results.addResult(new ValidationResult().type(ResultType.CONSTRAINT_VIOLATION).path(path).message("Array has too many items, > " + _minimumItems + ": " + coll));
}
boolean hasDuplicates = false;
Set<Object> set = Sets.newHashSet();
if (isTuple()) {
int tupleSize = _items.size();
int collSize = _items.size();
if (tupleSize > collSize) {
results.addResult(new ValidationResult().type(ResultType.CONSTRAINT_VIOLATION).path(path).message("Tuple is not the correct size, " + tupleSize + ": " + coll));
}
Iterator<JSONSchema> tupleIter = _items.iterator();
Iterator collIter = coll.iterator();
int index = 0;
while (tupleIter.hasNext() && collIter.hasNext()) {
JSONSchema tupleSchema = tupleIter.next();
Object tupleObj = collIter.next();
hasDuplicates = hasDuplicates || !set.add(tupleObj);
tupleSchema.validate(tupleObj, path + "[" + index + "]", results);
index++;
}
if (_additionalItemsSchema != null) {
while (collIter.hasNext()) {
Object additionalObj = collIter.next();
hasDuplicates = hasDuplicates || !set.add(additionalObj);
_additionalItemsSchema.validate(additionalObj, path + "[" + index + "]", results);
index++;
}
} else if (collIter.hasNext()) {
results.addResult(new ValidationResult().type(ResultType.CONSTRAINT_VIOLATION).path(path).message("Tuple does not allow additional items: " + coll));
}
} else {
int index = 0;
JSONSchema itemSchema = getItem();
for (final Object collObj : coll) {
hasDuplicates = hasDuplicates || !set.add(collObj);
itemSchema.validate(collObj, path + "[" + index + "]", results);
index++;
}
}
if (isSet() && hasDuplicates) {
results.addResult(new ValidationResult().type(ResultType.CONSTRAINT_VIOLATION).path(path).message("Set has duplicate items: " + coll));
}
}