Skip to content

Fix root falsy formData failing validation - #5423

Merged
heath-freenome merged 3 commits into
rjsf-team:mainfrom
charan-rathore:fix/root-falsy-form-data-validation
Oct 2, 2026
Merged

heath-freenome merged 3 commits into
rjsf-team:mainfrom
charan-rathore:fix/root-falsy-form-data-validation

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Reasons for making this change

Form.validate() used a truthy check when copying the root formData, so a falsy root value (false, 0, '') was treated as missing and validated as undefined. A form with type: boolean and a value of false failed with must be boolean and could never submit. Only undefined now skips the copy.

fixes #5404

Tests: it.each cases in packages/core/test/Form.handlers.test.tsx for root false, true, 0, integer 0 and '', plus a wrong-type negative case. The new cases that cover falsy values fail without the fix (16 failures on base).

Verification (author's run, I did not re-run it):

  • vitest for packages/core: 2106 passed, 0 failed.
  • oxlint and oxfmt clean; repo pre-commit hooks (18 projects) passed.
  • Not run: root tsc build, theme/snapshot/utils/validator suites (code untouched), and a browser check in the playground.

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I did not run pnpm run test:update; no snapshots are affected.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

Comment thread CHANGELOG.md Outdated
Comment on lines 23 to 24
- Fixed `Form` failing validation with `must be boolean` (or the matching type error) when the root `formData` is a falsy value such as `false`, `0` or `''`. Only `undefined` is now treated as missing before validating, fixes [#5404](https://github.com/rjsf-team/react-jsonschema-form/issues/5404) ([#5423](https://github.com/rjsf-team/react-jsonschema-form/pull/5423))
- Updated `markdown-to-jsx` from `^9.8.2` to `^9.10.3` ([#5420](https://github.com/rjsf-team/react-jsonschema-form/pull/5420))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this after existing entries

Suggested change
- Fixed `Form` failing validation with `must be boolean` (or the matching type error) when the root `formData` is a falsy value such as `false`, `0` or `''`. Only `undefined` is now treated as missing before validating, fixes [#5404](https://github.com/rjsf-team/react-jsonschema-form/issues/5404) ([#5423](https://github.com/rjsf-team/react-jsonschema-form/pull/5423))
- Updated `markdown-to-jsx` from `^9.8.2` to `^9.10.3` ([#5420](https://github.com/rjsf-team/react-jsonschema-form/pull/5420))
- Updated `markdown-to-jsx` from `^9.8.2` to `^9.10.3` ([#5420](https://github.com/rjsf-team/react-jsonschema-form/pull/5420))
- Fixed `Form` failing validation with `must be boolean` (or the matching type error) when the root `formData` is a falsy value such as `false`, `0` or `''`. Only `undefined` is now treated as missing before validating, fixing [#5404](https://github.com/rjsf-team/react-jsonschema-form/issues/5404)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, moved the entry below the markdown-to-jsx line, used your wording and dropped the PR link. Thanks Heath.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Size limit report

Sizes are minified + brotli, measured by size-limit at 7c571b8.

A package listed twice is measured both as installed and, on the second row, as its own code with its dependencies excluded. Peer dependencies are always excluded.

Check Base PR Δ
@rjsf/antd 6.85 kB 6.85 kB =
@rjsf/antd (without dependencies) 6.44 kB 6.44 kB =
@rjsf/chakra-ui 18.87 kB 18.87 kB =
@rjsf/chakra-ui (without dependencies) 10.83 kB 10.83 kB =
@rjsf/core 83.04 kB 83.18 kB +0.14 kB
@rjsf/core (without dependencies) 22.80 kB 22.79 kB =
@rjsf/core: Form 47.53 kB 47.46 kB -0.07 kB
@rjsf/daisyui 51.55 kB 51.55 kB =
@rjsf/daisyui (without dependencies) 9.58 kB 9.58 kB =
@rjsf/fluentui-rc 5.54 kB 5.54 kB =
@rjsf/mantine 11.45 kB 11.45 kB =
@rjsf/mantine (without dependencies) 7.05 kB 7.05 kB =
@rjsf/mui 6.30 kB 6.30 kB =
@rjsf/primereact 6.14 kB 6.14 kB =
@rjsf/react-bootstrap 7.55 kB 7.55 kB =
@rjsf/react-bootstrap (without dependencies) 5.29 kB 5.29 kB =
@rjsf/semantic-ui 5.26 kB 5.26 kB =
@rjsf/semantic-ui (without dependencies) 5.26 kB 5.26 kB =
@rjsf/shadcn 42.95 kB 42.95 kB =
@rjsf/shadcn (without dependencies) 8.61 kB 8.61 kB =
@rjsf/utils 30.38 kB 30.38 kB =
@rjsf/utils (without dependencies) 17.18 kB 17.18 kB =
@rjsf/utils: getUiOptions 0.31 kB 0.31 kB =
@rjsf/validator-ajv8 36.35 kB 36.35 kB =
@rjsf/validator-ajv8 (without dependencies) 2.55 kB 2.55 kB =
@rjsf/validator-ata 86.09 kB 86.09 kB =
@rjsf/validator-ata (without dependencies) 2.32 kB 2.32 kB =
@rjsf/validator-cfworker 7.19 kB 7.19 kB =
@rjsf/validator-cfworker (without dependencies) 2.29 kB 2.29 kB =

@heath-freenome
heath-freenome merged commit 2665ec3 into rjsf-team:main Oct 2, 2026
6 checks passed
jimmycallin pushed a commit to jimmycallin/react-jsonschema-form that referenced this pull request Oct 7, 2026
Brings in the main changes v7 did not already have from the earlier squashed
syncs (rjsf-team#5290, rjsf-team#5376, rjsf-team#5422):

- rjsf-team#5423: validate a falsy root formData (`false`, `0`, `''`) instead of
  treating it as missing, ported into v7's validateFormData()
- rjsf-team#5435: detect $ref cycles with a path-scoped recursion stack in
  retrieveSchema(), ported onto v7's SchemaContext signatures; its tests are
  adapted to `{ validator }` contexts and v7's stricter lint rules
- CHANGELOG.md taken from main (adds the 6.11.1 section)

Everything else main changed since 6.10.0 was already on v7, so those files
keep v7's content, including v7's theme snapshots. This is a real merge so
the merge base moves forward to main's tip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot submit form that has type boolean and value false

2 participants