Skip to content

Use format-appropriate names in validation error messages #595

@david-waltermire

Description

@david-waltermire

Summary

Validation error messages currently use JSON property names (getJsonName()) for identifying missing or invalid fields, even when parsing XML content. This can be confusing for users working with XML-only scenarios.

Current Behavior

When parsing XML and a required field is missing, the error message references the JSON property name:

Missing required property: some-json-name

Proposed Behavior

Error messages should adapt based on the parsing context:

  • JSON/YAML parsing: Use JSON property name
  • XML parsing: Use XML element/attribute name

Example for XML:

Missing required element: some-xml-element

Affected Code

  • AbstractProblemHandler.java - isRequiredAndMissingDefault() and related methods use getJsonName()
  • DefaultXmlProblemHandler.java - Should use XML names
  • DefaultJsonProblemHandler.java - Should continue using JSON names

Implementation Notes

  • The IBoundProperty interface provides both getJsonName() and getXmlQName() methods
  • Format context would need to be passed through the problem handler hierarchy
  • Consider whether to use qualified names or local names for XML

Related

This was identified during PR #593 code review as a nice-to-have improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions