Skip to content

Commit 3aa6b7b

Browse files
committed
Merge branch 'readme-1.9.0'
2 parents 5e6d677 + 2680874 commit 3aa6b7b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [JSON report of the failures](#json-report-of-the-failures)
1212
* [Eary failure mode](#early-failure-mode)
1313
* [Default values](#default-values)
14+
* [RegExp implementations](#regexp-implementations)
1415
* [readOnly and writeOnly context](#readonly-and-writeonly-context)
1516
* [Format validators](#format-validators)
1617
* [Example](#example)
@@ -269,6 +270,29 @@ System.out.println(input.get("prop")); // prints 1
269270
If there are some properties missing from `input` which have `"default"` values in the schema, then they will be set by the validator
270271
during validation.
271272

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+
272296
## readOnly and writeOnly context
273297

274298
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

Comments
 (0)