In Plone 5.1, I am attempting to write a validator for a datagrid field. When editing the content, I want to skip validation for values that are not being changed. This requires knowing the context in which the field is being used.
Considering this: 1. Validators — z3c.form 5.2.dev0 documentation
Finally, the context is available as attribute directly:
>>> data.__context__ is context
It is used by the validators (especially invariant validators) to provide a context of validation, for example to look up a vocabulary or access the parent of an object. Note that the context will be different between add and edit forms.
and finding an example that is very close to my use case here: Dexterity: Unique field validation - #2 by tmassman I look forward to a fairly simple task...
But instead, I discover that the
z3c.form.validator.Data object in a DGF does not have a
__context__ attribute. The known DGF workaround to get the context via
getRequest() returns a
I don't know how to get the context from it, or its acquisition parents.
Edit: or should I just forget about this approach and write an adapter, following Validation — Plone Documentation v5.2