|
2 | 2 |
|
3 | 3 | /**
|
4 | 4 | * Interface to capture which schemas are matching against a specific event in the {@code ValidatingVisitor}.
|
| 5 | + * <p> |
| 6 | + * All methods of this interface have a default empty implementation, so if an interface implementation is |
| 7 | + * interested only about a few specific event types, there is no need to add empty overrides of the unhandles events. |
| 8 | + * </p> |
5 | 9 | */
|
6 | 10 | public interface ValidationListener {
|
7 | 11 |
|
| 12 | + /** |
| 13 | + * Default no-operation implementation |
| 14 | + */ |
8 | 15 | ValidationListener NOOP = new ValidationListener() {
|
9 | 16 | };
|
10 | 17 |
|
| 18 | + /** |
| 19 | + * Called when a {@link org.everit.json.schema.CombinedSchema}'s given subschema matches the instance. |
| 20 | + * <p> |
| 21 | + * The {@link org.everit.json.schema.CombinedSchema} (which means an {@code "allOf"} or {@code "anyOf"} or |
| 22 | + * {@code "oneOf"} schema) can be referenced by calling {@link CombinedSchemaMatchEvent#getSchema()} and the |
| 23 | + * matching subschema is returned by {@link CombinedSchemaMatchEvent#getSubSchema()}. |
| 24 | + * </p> |
| 25 | + */ |
11 | 26 | default void combinedSchemaMatch(CombinedSchemaMatchEvent event) {
|
12 | 27 | }
|
13 | 28 |
|
| 29 | + /** |
| 30 | + * Called when a {@link org.everit.json.schema.CombinedSchema}'s given subschema does not match the instance. |
| 31 | + * <p> |
| 32 | + * The {@link org.everit.json.schema.CombinedSchema} (which means an {@code "allOf"} or {@code "anyOf"} or |
| 33 | + * {@code "oneOf"} schema) can be referenced by calling {@link CombinedSchemaMismatchEvent#getSchema()} and the |
| 34 | + * matching subschema is returned by {@link CombinedSchemaMismatchEvent#getSubSchema()}. The validation failure |
| 35 | + * of the subschema is returned by {@link CombinedSchemaMismatchEvent#getFailure()}. |
| 36 | + * </p> |
| 37 | + * |
| 38 | + * <p> |
| 39 | + * <em>Note: the invocation of this method by the validator does not necessarily mean that the validation |
| 40 | + * against the {@link org.everit.json.schema.CombinedSchema} will fail. In the case of the {@code "anyOf"} and |
| 41 | + * {@code "oneOf"} schemas it can be an intermediate failure while the root-level schema validation still |
| 42 | + * passes.</em> |
| 43 | + * </p> |
| 44 | + */ |
| 45 | + |
14 | 46 | default void combinedSchemaMismatch(CombinedSchemaMismatchEvent event) {
|
15 | 47 | }
|
16 | 48 |
|
| 49 | + /** |
| 50 | + * Called when a {@code "$ref"} JSON reference is resolved. |
| 51 | + * <p> |
| 52 | + * The referred schema is returned by {@link SchemaReferencedEvent#getReferredSchema()}, and the |
| 53 | + * {@link org.everit.json.schema.ReferenceSchema "$ref"} itself is returned by |
| 54 | + * {@link SchemaReferencedEvent#getSchema()} |
| 55 | + * </p> |
| 56 | + */ |
17 | 57 | default void schemaReferenced(SchemaReferencedEvent event) {
|
18 | 58 | }
|
19 | 59 |
|
| 60 | + /** |
| 61 | + * Called when an {@code "if"} schema matches. |
| 62 | + * <p> |
| 63 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 64 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 65 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 66 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#IF} in this method. |
| 67 | + * </p> |
| 68 | + * |
| 69 | + * <p> |
| 70 | + * <em>Note: the invocation of this method does not necessarily mean that the validation of the |
| 71 | + * {@link org.everit.json.schema.ConditionalSchema} will succeed. Instead it means that the evaluation continues |
| 72 | + * with the {@code "then"} schema.</em> |
| 73 | + * </p> |
| 74 | + */ |
20 | 75 | default void ifSchemaMatch(ConditionalSchemaMatchEvent event) {
|
21 | 76 | }
|
22 | 77 |
|
| 78 | + /** |
| 79 | + * Called when the instance does not pass the validation against an {@code "if"} schema. |
| 80 | + * <p> |
| 81 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 82 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 83 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 84 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#IF} in this method. |
| 85 | + * </p> |
| 86 | + * |
| 87 | + * <p> |
| 88 | + * <em>Note: the invocation of this method does not necessarily mean that the validation of the |
| 89 | + * {@link org.everit.json.schema.ConditionalSchema} will fail. Instead it means that the evaluation continues |
| 90 | + * with the {@code "else"} schema.</em> |
| 91 | + * </p> |
| 92 | + */ |
23 | 93 | default void ifSchemaMismatch(ConditionalSchemaMismatchEvent event) {
|
24 | 94 | }
|
25 | 95 |
|
| 96 | + /** |
| 97 | + * Called when the instance passes the validation against a {@code "then"} schema. |
| 98 | + * <p> |
| 99 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 100 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 101 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 102 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#THEN} in this method. |
| 103 | + * </p> |
| 104 | + */ |
26 | 105 | default void thenSchemaMatch(ConditionalSchemaMatchEvent event) {
|
27 | 106 | }
|
28 | 107 |
|
| 108 | + /** |
| 109 | + * Called when the instance does not pass the validation against a {@code "then"} schema. |
| 110 | + * <p> |
| 111 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 112 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 113 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 114 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#THEN} in this method. |
| 115 | + * </p> |
| 116 | + */ |
29 | 117 | default void thenSchemaMismatch(ConditionalSchemaMismatchEvent event) {
|
30 | 118 | }
|
31 | 119 |
|
| 120 | + /** |
| 121 | + * Called when the instance passes the validation against a {@code "else"} schema. |
| 122 | + * <p> |
| 123 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 124 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 125 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 126 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#ELSE} in this method. |
| 127 | + * </p> |
| 128 | + */ |
32 | 129 | default void elseSchemaMatch(ConditionalSchemaMatchEvent event) {
|
33 | 130 |
|
34 | 131 | }
|
35 | 132 |
|
| 133 | + /** |
| 134 | + * Called when the instance does not pass the validation against a {@code "else"} schema. |
| 135 | + * <p> |
| 136 | + * The {@link org.everit.json.schema.ConditionalSchema} (holding both the {@code "if"}, {@code "then"} and |
| 137 | + * {@code "else"} schemas) is returned by {@link ConditionalSchemaMatchEvent#getSchema()}, and |
| 138 | + * {@link ConditionalSchemaMatchEvent#getKeyword()} always returns |
| 139 | + * {@link org.everit.json.schema.event.ConditionalSchemaValidationEvent.Keyword#ELSE} in this method. |
| 140 | + * </p> |
| 141 | + */ |
36 | 142 | default void elseSchemaMismatch(ConditionalSchemaMismatchEvent event) {
|
37 | 143 | }
|
38 | 144 | }
|
|
0 commit comments