rjsf-team/react-jsonschema-form

Dependency errors do not show `title` or `ui:title`

Open

#4,402 创建于 2024年11月29日

在 GitHub 查看
 (5 评论) (1 反应) (0 负责人)TypeScript (13,175 star) (2,136 fork)batch import
awaiting responsebughelp wanted

描述

Prerequisites

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:

  1. ajv does not enclose raw property names with quotes (see here) while transformRJSFValidationErrors() expects property names are enclosed.
  2. transformRJSFValidationErrors() only handles missingProperty (see this block). property and deps should 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

贡献者指南