1 /* 2 * Copyright (c) 2024 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.networknt.schema; 17 18 import static org.junit.jupiter.api.Assertions.assertTrue; 19 20 import java.util.Set; 21 22 import org.junit.jupiter.api.Test; 23 24 import com.networknt.schema.SpecVersion.VersionFlag; 25 26 public class Issue857Test { 27 @Test test()28 void test() { 29 String schema = "{\r\n" 30 + " \"type\": \"object\",\r\n" 31 + " \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\r\n" 32 + " \"properties\": {\r\n" 33 + " \"id\": {\r\n" 34 + " \"not\": {\r\n" 35 + " \"enum\": [\r\n" 36 + " \"1\",\r\n" 37 + " \"2\",\r\n" 38 + " \"3\"\r\n" 39 + " ]\r\n" 40 + " },\r\n" 41 + " \"type\": \"string\"\r\n" 42 + " }\r\n" 43 + " },\r\n" 44 + " \"$id\": \"https://d73abc/filter.json\"\r\n" 45 + "}"; 46 47 String input = "{\r\n" 48 + " \"id\": \"4\"\r\n" 49 + "}"; 50 51 SchemaValidatorsConfig config = new SchemaValidatorsConfig(); 52 config.setFailFast(true); 53 JsonSchemaFactory factory = JsonSchemaFactory.getInstance(VersionFlag.V202012); 54 Set<ValidationMessage> result = factory.getSchema(schema, config).validate(input, InputFormat.JSON); 55 assertTrue(result.isEmpty()); 56 } 57 } 58