void (@NotNull JsonValueAdapter array, final @NotNull List<JsonValueAdapter> list, final JsonSchemaObject schema, JsonValidationHost consumer, JsonComplianceCheckerOptions options) { if (schema.isUniqueItems()) { final MultiMap<String, JsonValueAdapter> valueTexts = new MultiMap<>(); final JsonLikePsiWalker walker = JsonLikePsiWalker.getWalker(array.getDelegate(), schema); assert walker != null; for (JsonValueAdapter adapter : list) { valueTexts.putValue(walker.getNodeTextForValidation(adapter.getDelegate()), adapter); } for (Map.Entry<String, Collection<JsonValueAdapter>> entry: valueTexts.entrySet()) { if (entry.getValue().size() > 1) { for (JsonValueAdapter item: entry.getValue()) { if (!item.shouldCheckAsValue()) continue; consumer.error(JsonBundle.message("schema.validation.not.unique"), item.getDelegate(), JsonErrorPriority.TYPE_MISMATCH); } } } } if (schema.getContainsSchema() != null) { boolean match = false; for (JsonValueAdapter item: list) { final JsonValidationHost checker = consumer.checkByMatchResult(item, consumer.resolve(schema.getContainsSchema()), options); if (checker == null || checker.isValid()) { match = true; break; } } if (!match) { consumer.error(JsonBundle.message("schema.validation.array.not.contains"), array.getDelegate(), JsonErrorPriority.MEDIUM_PRIORITY); } } if (schema.getItemsSchema() != null) { for (JsonValueAdapter item : list) { consumer.checkObjectBySchemaRecordErrors(schema.getItemsSchema(), item); } } else if (schema.getItemsSchemaList() != null) { final Iterator<JsonSchemaObject> iterator = schema.getItemsSchemaList().iterator(); for (JsonValueAdapter arrayValue : list) { if (iterator.hasNext()) { consumer.checkObjectBySchemaRecordErrors(iterator.next(), arrayValue); } else { if (!Boolean.TRUE.equals(schema.getAdditionalItemsAllowed())) { consumer.error(JsonBundle.message("schema.validation.array.no.extra"), arrayValue.getDelegate(), JsonErrorPriority.LOW_PRIORITY); } else if (schema.getAdditionalItemsSchema() != null) { consumer.checkObjectBySchemaRecordErrors(schema.getAdditionalItemsSchema(), arrayValue); } } } } if (schema.getMinItems() != null && list.size() < schema.getMinItems()) { consumer.error(JsonBundle.message("schema.validation.array.shorter.than", schema.getMinItems()), array.getDelegate(), JsonErrorPriority.LOW_PRIORITY); } if (schema.getMaxItems() != null && list.size() > schema.getMaxItems()) { consumer.error(JsonBundle.message("schema.validation.array.longer.than", schema.getMaxItems()), array.getDelegate(), JsonErrorPriority.LOW_PRIORITY); } // these two are not correct by the schema spec, but are used in some schemas if (schema.getMinLength() != null && list.size() < schema.getMinLength()) { consumer.error(JsonBundle.message("schema.validation.array.shorter.than", schema.getMinLength()), array.getDelegate(), JsonErrorPriority.LOW_PRIORITY); } if (schema.getMaxLength() != null && list.size() > schema.getMaxLength()) { consumer.error(JsonBundle.message("schema.validation.array.longer.than", schema.getMaxLength()), array.getDelegate(), JsonErrorPriority.LOW_PRIORITY); } }