rjsf-team/react-jsonschema-form

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

Open

#4136 aperta il 19 mar 2024

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)TypeScript (2136 fork)batch import
awaiting responsebughelp wanted

Metriche repository

Star
 (13.175 star)
Metriche merge PR
 (Merge medio 3g 17h) (32 PR mergiate in 30 g)

Descrizione

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.

Guida contributor