rjsf-team/react-jsonschema-form

Schema defines standalone checkbox as mandatory, but asterisk is not rendered.

Open

#4,136 建立於 2024年3月19日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)TypeScript (13,175 star) (2,136 fork)batch import
awaiting responsebughelp wanted

描述

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Making a standalone checkbox mandatory does NOT render an asterisk. Refer to schema below in 'Steps to reproduce'

Form renders ok, errors shown up when clicking submit button, but no asterisk shows up.

Expected Behavior

Making a standalone checkbox mandatory should render an asterisk, so behavior is consistent across this package.

Steps To Reproduce

This is the schema I am using

const schema: RJSFSchema = {
    title: "User Information", //fieldset-Legend
    type: "object",
    required: ["firstName", "IAgreeCheckbox"], // These fields are mandatory;
    properties: {
      firstName: {
        title: "First Name",
        type: "string",
        minLength: 2,
        maxLength:20,
        pattern: "^[A-Za-z'-]*$"
      },
      age: {
        title: "Age",
        type: "number",
        minimum:18,
        maximum:100
      },
      //single-checkbox:
      IAgreeCheckbox: {
        type: "boolean",
        title: "I Agree with All the above",
        const: true //Must check
      }
    }
  };

/* Field-level error message: Must be equal to constant.

Form-level error message: 'I Agree with All the above' must be equal to constant */

Environment

- OS:Windows 11
- Node: v14.20.0 (not relevant)
- npm: 6.14.17 (not relevant)

Anything else?

It's a basic problem, the library should behave consistently.

貢獻者指南