|
| 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.*; |
| 19 | + |
| 20 | +import org.junit.jupiter.api.Test; |
| 21 | + |
| 22 | +import com.networknt.schema.SpecVersion.VersionFlag; |
| 23 | + |
| 24 | +/** |
| 25 | + * PatternValidatorTest. |
| 26 | + */ |
| 27 | +class PatternValidatorTest { |
| 28 | + @Test |
| 29 | + void failFast() { |
| 30 | + String schemaData = "{\r\n" |
| 31 | + + " \"type\": \"string\",\r\n" |
| 32 | + + " \"pattern\": \"^(\\\\([0-9]{3}\\\\))?[0-9]{3}-[0-9]{4}$\"\r\n" |
| 33 | + + "}"; |
| 34 | + String inputData = "\"hello\""; |
| 35 | + JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V202012).getSchema(schemaData); |
| 36 | + boolean result = schema.validate(inputData, InputFormat.JSON, OutputFormat.BOOLEAN); |
| 37 | + assertFalse(result); |
| 38 | + } |
| 39 | + |
| 40 | +} |
0 commit comments