diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
index 865c6efdefbb..44f8ace10af8 100644
--- a/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
+++ b/json/src/com/jetbrains/jsonSchema/impl/JsonBySchemaObjectAnnotator.java
@@ -188,39 +188,36 @@ class JsonBySchemaObjectAnnotator implements Annotator {
final JsonSchemaType type = getType(value);
if (type == null) {
typeError(value);
- return;
+ } else {
+ JsonSchemaType schemaType = matchSchemaType(schema, type);
+ if (schemaType == null && schema.hasSpecifiedType()) {
+ typeError(value);
+ }
+ else if (JsonSchemaType._boolean.equals(type)) {
+ checkForEnum(value, schema);
+ }
+ else if (JsonSchemaType._number.equals(type) || JsonSchemaType._integer.equals(type)) {
+ checkNumber(value, schema, schemaType);
+ checkForEnum(value, schema);
+ }
+ else if (JsonSchemaType._string.equals(type)) {
+ checkString(value, schema);
+ checkForEnum(value, schema);
+ }
+ else if (JsonSchemaType._array.equals(type)) {
+ checkArray(value, schema);
+ checkForEnum(value, schema);
+ }
+ else if (JsonSchemaType._object.equals(type)) {
+ checkObject(value, schema, validatedProperties);
+ checkForEnum(value, schema);
+ }
}
- JsonSchemaType schemaType = matchSchemaType(schema, type);
- if (schemaType == null && schema.hasSpecifiedType()) {
- typeError(value);
- return;
- }
- if (JsonSchemaType._boolean.equals(type)) {
- checkForEnum(value, schema);
- return;
- }
- if (JsonSchemaType._number.equals(type) || JsonSchemaType._integer.equals(type)) {
- checkNumber(value, schema, schemaType);
- checkForEnum(value, schema);
- return;
- }
- if (JsonSchemaType._string.equals(type)) {
- checkString(value, schema);
- checkForEnum(value, schema);
- return;
- }
- if (JsonSchemaType._array.equals(type)) {
- checkArray(value, schema);
- checkForEnum(value, schema);
- return;
- }
- if (JsonSchemaType._object.equals(type)) {
- checkObject(value, schema, validatedProperties);
- checkForEnum(value, schema);
- return;
- }
- if (JsonSchemaType._null.equals(type)) {
- return;
+
+ if (schema.getNot() != null) {
+ final BySchemaChecker checker = new BySchemaChecker();
+ checker.checkByScheme(value, schema.getNot(), new HashSet<>());
+ if (checker.isCorrect()) error("Validates against 'not' schema", value);
}
}
diff --git a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java
index 15d11be2fadc..5cabd3d5ca31 100644
--- a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java
+++ b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java
@@ -439,6 +439,25 @@ public class JsonSchemaHighlightingTest extends DaemonAnalyzerTestCase {
testImpl(schema, text);
}
+ public void testNotSchema() throws Exception {
+ final String schema = "{\"properties\": {\n" +
+ " \"not_type\": { \"not\": { \"type\": \"string\" } }\n" +
+ " }}";
+ testImpl(schema, "{\"not_type\": \"wrong\"}");
+ }
+
+ public void testNotSchemaCombinedWithNormal() throws Exception {
+ final String schema = "{\"properties\": {\n" +
+ " \"not_type\": {\n" +
+ " \"pattern\": \"^[a-z]*[0-5]*$\",\n" +
+ " \"not\": { \"pattern\": \"^[a-z]{1}[0-5]$\" }\n" +
+ " }\n" +
+ " }}";
+ testImpl(schema, "{\"not_type\": \"va4\"}");
+ testImpl(schema, "{\"not_type\": \"a4\"}");
+ testImpl(schema, "{\"not_type\": \"4a4\"}");
+ }
+
public static String rootObjectRedefinedSchema() {
return "{\n" +
" \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n" +