rjsf-team/react-jsonschema-form
View on GitHubDependency errors do not show `title` or `ui:title`
Open
#4402 opened on Nov 29, 2024
awaiting responsebughelp wanted
Description
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
validator-ajv8
Version
5.23.1
Current Behavior
Dependency errors do not show title or ui:title.
const Ajv2019 = require('ajv/dist/2019');
const { customizeValidator } = require('@rjsf/validator-ajv8');
const schema = {
type: 'object',
properties: {
creditCard: {
type: 'number',
title: 'Credit card',
},
billingAddress: {
type: 'string',
title: 'Billing address',
},
},
dependentRequired: {
creditCard: ['billingAddress'],
},
};
const validator = customizeValidator({ AjvClass: Ajv2019 });
const result = validator.validateFormData({ creditCard: 1234567890 }, schema);
console.log(result.errors[0].message);
This results in must have property billingAddress when property creditCard is present.
Expected Behavior
must have property 'Billing address' when property 'Credit card' is present is expected.
There are two possible causes:
ajvdoes not enclose raw property names with quotes (see here) while transformRJSFValidationErrors() expects property names are enclosed.transformRJSFValidationErrors()only handlesmissingProperty(see this block).propertyanddepsshould be handled as well.
Steps To Reproduce
Please see above.
Environment
- OS: Ubuntu 24.04
- Node: 18.20.2
- npm: 10.5.0
Anything else?
No response