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 (2,136 fork)batch import
awaiting responsebughelp wanted

倉庫指標

Star
 (13,175 star)
PR 合併指標
 (平均合併 3天 17小時) (30 天內合併 32 個 PR)

描述

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

貢獻者指南