@@ -35,20 +35,21 @@ public PatternValidator(String schemaPath, JsonNode schemaNode, JsonSchema paren
35
35
36
36
this .pattern = Optional .ofNullable (schemaNode ).filter (JsonNode ::isTextual ).map (JsonNode ::textValue ).orElse (null );
37
37
try {
38
- this .compiledPattern = RegularExpression .compile (pattern , validationContext );
38
+ this .compiledPattern = RegularExpression .compile (this . pattern , validationContext );
39
39
} catch (RuntimeException e ) {
40
40
e .setStackTrace (new StackTraceElement [0 ]);
41
- logger .error ("Failed to compile pattern '{}': {}" , pattern , e .getMessage ());
41
+ logger .error ("Failed to compile pattern '{}': {}" , this . pattern , e .getMessage ());
42
42
throw e ;
43
43
}
44
44
this .validationContext = validationContext ;
45
45
parseErrorCode (getValidatorType ().getErrorCodeKey ());
46
46
}
47
47
48
48
private boolean matches (String value ) {
49
- return compiledPattern .matches (value );
49
+ return this . compiledPattern .matches (value );
50
50
}
51
51
52
+ @ Override
52
53
public Set <ValidationMessage > validate (JsonNode node , JsonNode rootNode , String at ) {
53
54
debug (logger , node , rootNode , at );
54
55
@@ -59,10 +60,13 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
59
60
60
61
try {
61
62
if (!matches (node .asText ())) {
62
- return Collections .singleton (buildValidationMessage (at , pattern ));
63
+ return Collections .singleton (buildValidationMessage (at , this . pattern ));
63
64
}
65
+ } catch (JsonSchemaException e ) {
66
+ throw e ;
64
67
} catch (RuntimeException e ) {
65
- logger .error ("Failed to apply pattern '{}' at {}: {}" , pattern , at , e .getMessage ());
68
+ logger .error ("Failed to apply pattern '{}' at {}: {}" , this .pattern , at , e .getMessage ());
69
+ throw e ;
66
70
}
67
71
68
72
return Collections .emptySet ();
0 commit comments