-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
This is a very good library with solid coverage of the JSON schema spec. However, both JSON and JSON schema especially have a few corner cases that are particularly difficult to handle. JSON itself has the whole "what's a number, really?" thing, and JSON schema has a few interesting corners in the spec like:
- multipleOf with floats
- Mandating JS regexen, but also recommending to only actually use EREs
- Complex date/time parsing
These add considerable amounts of code to jsonschema; fancy regex and the "high-end" regex crate seem to add up to about 1 MB of code these days. Just the special case of multipleOf with a float multiple adds a bignum math library.
I suspect that many end-users don't use these corners of the spec (I know I don't) and could benefit from a "lite" feature set:
- fewer dependencies means less code to keep an eye on,
- quicker compile times and
- smaller artifacts
I did some haphazard exploration of adding this and it doesn't seem to be particularly annoying. The biggest change would be introducing a module (or just a bunch of #[cfg] use in lib.rs) to select between the different regex engines for the different use-cases, since fancy-regex is only used for matching schema-supplied RE, while regex is used for internal REs. lite would switch both of these to regex-lite. The remainder is pretty much just a few cfg attributes to disable some validators. I haven't looked at tests though, yet.