Track the declared JSON Schema dialect in the validator state and validate
dialect-sensitive constructs before applying a schema.
Recognize draft-04, draft-06, draft-07, 2019-09, and 2020-12, while preserving
the existing compatibility behavior for schemas without a $schema declaration.
Reject unknown dialects and known keywords or forms that do not belong to the
declared draft.
Implement draft-specific exclusive bound semantics, boolean-schema rules, and
array vocabulary differences. Document the behavior and add coverage for all
supported drafts.
The generated Gajumaru draft-04 configuration schema passes the new checks.
The function `pure_update_config/3` updates the config and simply returns the new config, without any side-effects.
Co-authored-by: Ulf Wiger <ulf@wiger.net>
Reviewed-on: #4
In order to simplify deps, this PR makes config file formats pluggable. The extensions supported by default are "json" and "eterm".
The default json decoder is the one from OTP, but if one prefers another (e.g. `zj`), it's possible to choose that when installing the gmconfig env.
Example of adding a yaml decoder:
```erlang
instrument_gmconfig() ->
gmconfig:set_gmconfig_env(gmconfig_env()).
-spec gmconfig_env() -> gmconfig:gmconfig().
gmconfig_env() ->
#{ ...
, config_formats => add_yamerl() }.
add_yamerl() ->
Default = maps:get(config_formats, gmconfig:default_gmconfig_env()),
case maps:is_key("yaml", Default) of
true ->
Default;
false ->
Default#{"yaml" => fun yamerl_decode/1}
end.
yamerl_decode(Bin) ->
yamerl:decode(Bin, [{str_node_as_binary, true},
{map_node_format, map}]).
```
Co-authored-by: Ulf Wiger <ulf@wiger.net>
Reviewed-on: #1