Related to rjsf-team/react-jsonschema-form#4923
I continued working on the validator using this library and encountered the following issues:
-
The library is not published, so it cannot be specified as a peer dependency.
-
Errors still cannot be retrieved synchronously, for two reasons:
- Localization - in addition to being synchronous, it would be preferable to avoid using platform-specific APIs and ensure tree-shaking support
constructErrorIndex is asynchronous and not exposed in the public API
At the moment, I had to duplicate the implementations of Localization and constructErrorIndex in the validator project.
- When validating an object with missing properties, the library returns an error like this:
[
{
"message": "Missing required properties: id, email, and age",
"instanceLocation": "#",
"schemaLocations": [
"https://example.com/v0#/required"
]
}
]
This is correct and suitable for something like a REST API, but for form validation it would be preferable to get the following list (not structurally identical, but equivalent in content), so that errors can be displayed for specific fields:
[
{
"message": "Missing required property: id",
"path": ["id"]
},
{
"message": "Missing required property: email",
"path": ["email"]
},
{
"message": "Missing required property: age",
"path": ["age"]
}
]
Here is how it currently works with AJV:
- Each field has its own error
- Errors include metadata such as
missingProperty, propertyName
- If metadata is present, the validator appends it to the
instancePath during error processing
Related to rjsf-team/react-jsonschema-form#4923
I continued working on the validator using this library and encountered the following issues:
The library is not published, so it cannot be specified as a peer dependency.
Errors still cannot be retrieved synchronously, for two reasons:
constructErrorIndexis asynchronous and not exposed in the public APIAt the moment, I had to duplicate the implementations of
LocalizationandconstructErrorIndexin the validator project.[ { "message": "Missing required properties: id, email, and age", "instanceLocation": "#", "schemaLocations": [ "https://example.com/v0#/required" ] } ]This is correct and suitable for something like a REST API, but for form validation it would be preferable to get the following list (not structurally identical, but equivalent in content), so that errors can be displayed for specific fields:
[ { "message": "Missing required property: id", "path": ["id"] }, { "message": "Missing required property: email", "path": ["email"] }, { "message": "Missing required property: age", "path": ["age"] } ]Here is how it currently works with
AJV:missingProperty,propertyNameinstancePathduring error processing