Uploaded image for project: 'Metadata Aggregator'
  1. Metadata Aggregator
  2. MDA-233

Better value context indication from validators



    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 0.10.0
    • Component/s: Validation
    • Labels:


      The current Validator interface has the following (stripped down) method:

      Action validate(V e, Item<?> item, @Nonnull String stageId)

      Here we have a value v to process, an item where we can put item metadata such as ErrorStatus, and a stage identifier to use in constructing that item metadata's componentId, normally by combining it with the validator's own identifier (so that we end up with something like stage/validator).

      This works well to tell us which component in the configuration has caused the validation to fail, but it doesn't help in determining where in a perhaps large and complex item's content tree the value came from.

      An improvement to this model would allow the validator's caller to optionally provide that information, perhaps by passing in a DOM element or attribute name which could then be integrated into the contents of the ErrorStatus.

      Action validate(V e, Item<?> item, @Nonnull String executionContext, @Nullable String valueContext)

      I'm spitballing identifiers here, but the idea is that one of the strings would indicate component structure as now (where at least some of the time stageId is a misnomer), and the other would be a hint as to where the value came from within the document.

      One of the two methods (probably the old one? this needs some thought) could be a default method to make it simpler to write validators that don't need this level of detail because the value itself (and the composite component identifier) is sufficient to identify the source.

      I'm working on some prototype validation components at present that would benefit from this, but outside the MDA project. In that work, I will probably pass the value context in as part of the "stageId" value, but that's going to end up with it appearing in strange places. When I come to upstreaming that work, it should be rewritten along these lines.




            ian@iay.org.uk Ian Young
            ian@iay.org.uk Ian Young
            0 Start watching this issue