Feature request: Trigger "warning" if specific value encountered in JSON field
We use the schema for JSON validation and that's great -> however, for some failures (or use cases), I would like to send a specific warning to the user.
Example:
- User tries to specify
RASinEEGCoordinateSystem RASis not on the [list of restricted keywords], the schema errors and prints a list of accepted values- among the printed list, there is
Other, and because it seems like the only fit, the user picksOtherand moves on
--> that's a problem, because if Other is specified in EEGCoordinateSystem, I want the user to specify a string for the EEGCoordinateSystemDescription field to explain in detail what Other means.
So ideally, the validator would provide a re-usable structure to check:
- if value A in field B of any JSON, do action X
- where Z could be either of:
- send a specifically phrased warning
- check value in field C ... and if that value is D, pass ... else raise specifically phrased warning
Does that sound reasonable?
this enhancement would be a neat and powerful way to improve validation and BIDS usage ... and just to draw attention back to another important (IMHO) and generalizable feature, please see: https://github.com/bids-standard/bids-validator/issues/672 ... if we could implement both of these, we'd be making a big step towards a better validation.
I think a part of this issue could be solved with JSON schema conditionals, but that wouldn't allow us to send out targeted warnings
more specifically, see: https://stackoverflow.com/a/38781027/5201771
Either the "foo" property does not equal "bar", or the "bar" property is required
{
"type": "object",
"properties": {
"foo": { "type": "string" },
"bar": { "type": "string" }
},
"anyOf": [
{
"not": {
"properties": {
"foo": { "const": "bar" }
},
"required": ["foo"]
}
},
{ "required": ["bar"] }
]
}
also related to https://github.com/bids-standard/bids-validator/issues/945 ... but the feature request here goes beyond that issue.
This can be done in the schema.