Currently, we only check constraints on the statement main snak. We should also check them on qualifiers and on references.
Does this apply to all constraint types or just some of them? There are “value only”, “qualifier only” and “reference only” constraint types, which only make sense with this feature. Constraints like “range”, “value type”, or “one of” make sense on qualifiers and references. On the other hand, “item required claim” and “type” don’t really make sense there, I think. But it might not hurt to just allow them anyways, and if people add those constraints, so be it.
---
Implementation idea: `checkConstraint` could take a `ConstraintContext` argument instead of the current `Statement` and `EntityDocument` arguments; the context would expose the entity, the statement, the snak to be checked, and what kind of context it is (is the snak the main snak, a qualifier, or a reference?).
This might require a breaking change to the API output format.
---
- [ ] Get new API format ready: {T174544}
- [x] [Add context for qualifiers](https://gerrit.wikimedia.org/r/#/c/373322/)
- [x] [Add context for references](https://gerrit.wikimedia.org/r/374995)
- [x] Update some constraint checkers (e. g. “conflicts with” probably conflicts with other qualifiers?) – not a blocker due to T175570, the various related tasks can be done later
- [ ] [Add config for checking constraints on qualifiers and references](https://gerrit.wikimedia.org/r/#/c/376290/) ~~(might be the same as the one for switching to the new API format)~~
- [ ] [Add support for checking constraints on qualifiers and references to extension](https://gerrit.wikimedia.org/r/#/c/379746/)
- [ ] [Add support for checking constraints on qualifiers and references to gadget](https://gerrit.wikimedia.org/r/#/c/379747/)
- [ ] Remove support for old API format (and config setting)
- …