|
11 | 11 | * [JSON report of the failures](#json-report-of-the-failures)
|
12 | 12 | * [Eary failure mode](#early-failure-mode)
|
13 | 13 | * [Default values](#default-values)
|
| 14 | +* [RegExp implementations](#regexp-implementations) |
14 | 15 | * [readOnly and writeOnly context](#readonly-and-writeonly-context)
|
15 | 16 | * [Format validators](#format-validators)
|
16 | 17 | * [Example](#example)
|
@@ -269,6 +270,29 @@ System.out.println(input.get("prop")); // prints 1
|
269 | 270 | If there are some properties missing from `input` which have `"default"` values in the schema, then they will be set by the validator
|
270 | 271 | during validation.
|
271 | 272 |
|
| 273 | +## RegExp Implementations |
| 274 | + |
| 275 | +For supporting the `"regex"` keyword of JSON Schema the library offers two possible implementations: |
| 276 | + * the default is based on the `java.util.regex` package |
| 277 | + * the other one is based on the [RE2J](https://github.com/google/re2j) library |
| 278 | + |
| 279 | +While the RE2J library provides significantly better performance than `java.util.regex`, it is not completely compatible with |
| 280 | +the syntax supported by `java.util` or ECMA 262. So RE2J is recommended if you are concerned about performance and its limitations are acceptable. |
| 281 | + |
| 282 | +The RE2J implementation can be activated with the `SchemaLoaderBuilder#regexpFactory()` call: |
| 283 | + |
| 284 | +```java |
| 285 | +SchemaLoader loader = SchemaLoader.builder() |
| 286 | + .regexpFactory(new RE2JRegexpFactory()) |
| 287 | + // ... |
| 288 | + .build(); |
| 289 | +``` |
| 290 | +Notes: |
| 291 | + - if you don't need the RE2J implementation, it is recommended to exclude it in your `pom.xml` so it doesn't increase your artifact's size unnecessarily |
| 292 | + - version history: in versions 1.0.0 ... 1.7.0 the `java.util` implementation was used, in 1.8.0 the RE2J implementation was used, and in 1.9.0 we made it |
| 293 | +configurable, due to some reported regressions. |
| 294 | + |
| 295 | + |
272 | 296 | ## readOnly and writeOnly context
|
273 | 297 |
|
274 | 298 | The library supports the `readOnly` and `writeOnly` keywords which first appeared in Draft 7. If you want to utilize this feature, then before validation you need to tell the vaildator if the
|
|
0 commit comments