Skip to content

Boolean schema false is ignored #4528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks done
rap1ds opened this issue Mar 17, 2025 · 2 comments
Open
4 tasks done

Boolean schema false is ignored #4528

rap1ds opened this issue Mar 17, 2025 · 2 comments

Comments

@rap1ds
Copy link

rap1ds commented Mar 17, 2025

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Given the following schema:

{
  "type": "number",
  "if": {
    "const": 13
  },
  "then": false
}

Value 13 is a valid value.

Expected Behavior

In JSON Schema, false equals {"not": {}} link to spec

Thus, the schema above with value 13 should be invalid.

Steps To Reproduce

  1. Playground example
  2. Input value 13
  3. Click Submit

Expected: validation fails

Actual: Form submitted

If you click "Raw validate", you can see the AJV validation error.

Environment

Playground

Anything else?

Please note that if false is replaced with {"not": {}}, everything works as expected: playground

@rap1ds rap1ds added bug needs triage Initial label given, to be assigned correct labels and assigned labels Mar 17, 2025
@heath-freenome heath-freenome added help wanted and removed needs triage Initial label given, to be assigned correct labels and assigned labels Mar 21, 2025
@heath-freenome
Copy link
Member

@rap1ds Wow, that's weird. Is this something you are willing to dig deeper into and perhaps provide a bug fix for the ajv8 validator?

@nickgros
Copy link
Contributor

nickgros commented Mar 21, 2025

For some reason the schema passed to rawValidation is just { "type": "number" }, so there's a bug in schemaUtils.retrieveSchema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants