这是indexloc提供的服务,不要输入任何密码
Skip to content

Validating JSON outside of a request #121

@nickajacks1

Description

@nickajacks1

The validation is great, and it would be nice to be able to use it outside the context of a request (e.g., JSON file validation). However, the public interface is somewhat awkward due to the included optimizations.
Would it be in the spirit of things to add a simplified interface for generic schema validation? Or does supporting such a feature go out of the scope of Huma?

A few details that could potentially be abstracted away:

  • The Registry parameter is used only if the schema is a reference (or is a parent to one, recursively)
  • The PathBuffer could potentially be made optional
  • ValidateMode could have a default (or be ignored?)
  • ValidateResult could implement Error() and be returned as an error

I feel like a lot of the extra details could be abstracted away without giving up the optimizations.
For example, a config/option struct could be used that provides reasonable defaults.

Another approach might be to create a wrapper function that simplifies use (or even just suggest that users create one themselves).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions