barectf: schemas: use conditionals intead of `oneOf` when possible
Using `if`/`then`/`else` instead of `oneOf` makes the `jsonschema`
validator create much more readable errors.
For example:
Before:
Error:
Configuration: Cannot create configuration from YAML file
`config.yaml`
Configuration object:
`metadata` property:
`clocks` property:
`some_clock` property:
`offset` property:
`seconds` property: -2 is not valid under any of the given
schemas: -2 is less than the minimum of 0; -2 is not of type
'null' (from schema `2/config/config`)
Now:
Error:
Configuration: Cannot create configuration from YAML file
`config.yaml`
Configuration object:
`metadata` property:
`clocks` property:
`some_clock` property:
`offset` property:
`seconds` property: -2 is less than the minimum of 0
(from schema `2/config/config`)
This is because, with conditionals, we assume that the user intended
something with some valid schema, and add more constraints. The example
above is for an integer having a minimum value of 0, or a null value. As
soon as we know that the value is an integer, then we know its minimum
must be 0; we decide to not care about the fact that the whole value
could also be null (which the old message indicated). In my opinion,
this is a better UX.
The example above is simple. For more complex schemas, the UX gain is
even more obvious.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.023299 seconds and 4 git commands to generate.