Skip to content
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

AJV8 additionalProperties validation broken in playground #3213

Closed
4 tasks done
rap1ds opened this issue Oct 27, 2022 · 1 comment
Closed
4 tasks done

AJV8 additionalProperties validation broken in playground #3213

rap1ds opened this issue Oct 27, 2022 · 1 comment
Assignees
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@rap1ds
Copy link

rap1ds commented Oct 27, 2022

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

In the playground, with the AJV8 validator, form data with additional keys that don't match the schema are valid and the form is submitted.

Playground: https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJmaXJzdE5hbWUiOiJDaHVjayIsImxhc3ROYW1lIjoiTm9ycmlzIiwiYXNzS2lja0NvdW50IjoxMjN9LCJzY2hlbWEiOnsidGl0bGUiOiJBIGN1c3RvbWl6YWJsZSByZWdpc3RyYXRpb24gZm9ybSIsImRlc2NyaXB0aW9uIjoiQSBzaW1wbGUgZm9ybSB3aXRoIGFkZGl0aW9uYWwgcHJvcGVydGllcyBleGFtcGxlLiIsInR5cGUiOiJvYmplY3QiLCJyZXF1aXJlZCI6WyJmaXJzdE5hbWUiLCJsYXN0TmFtZSJdLCJhZGRpdGlvbmFsUHJvcGVydGllcyI6eyJ0eXBlIjoic3RyaW5nIn0sInByb3BlcnRpZXMiOnsiZmlyc3ROYW1lIjp7InR5cGUiOiJzdHJpbmciLCJ0aXRsZSI6IkZpcnN0IG5hbWUifSwibGFzdE5hbWUiOnsidHlwZSI6InN0cmluZyIsInRpdGxlIjoiTGFzdCBuYW1lIn19fSwidWlTY2hlbWEiOnsiZmlyc3ROYW1lIjp7InVpOmF1dG9mb2N1cyI6dHJ1ZSwidWk6ZW1wdHlWYWx1ZSI6IiJ9fSwidGhlbWUiOiJkZWZhdWx0IiwibGl2ZVNldHRpbmdzIjp7InNob3dFcnJvckxpc3QiOiJ0b3AiLCJ2YWxpZGF0ZSI6ZmFsc2UsImRpc2FibGUiOmZhbHNlLCJyZWFkb25seSI6ZmFsc2UsIm9taXRFeHRyYURhdGEiOmZhbHNlLCJsaXZlT21pdCI6ZmFsc2V9fQ==

Please note that I tried this only on playground since locally I'm still using old AJV6 on my project.

Expected Behavior

additionalProperties is set to type "string", thus, number value such as 123 should fail to validate.

AJV6 (deprecated) validator behaves as expected and gives validation error "assKickCount should be string"

Steps To Reproduce

  1. Go to Playground
  2. Pick the "Additional Properties" example
  3. Select AJV8_xx validator
  4. Change formData value of assKickCount to any number, e.g. 123.
  5. Click Submit

Environment

- Playground

Anything else?

No response

@rap1ds rap1ds added bug needs triage Initial label given, to be assigned correct labels and assigned labels Oct 27, 2022
@nickgros nickgros self-assigned this Oct 31, 2022
nickgros added a commit to nickgros/react-jsonschema-form that referenced this issue Nov 5, 2022
Playground
- Playground `localValidator` should use @rjsf/validator-ajv8
- Upgrade Vite and @vitejs/plugin-react to latest

@rjsf/validator-ajv8
- Alias `ajv` to `ajv8` because in the playground, Vite erroneously imports Ajv 6
- Report any schema error thrown by Ajv
- Disable Ajv's strict mode by default
- Add RJSF-specific additional properties keywords to Ajv to prevent errors from being reported in strict mode.
-
nickgros added a commit that referenced this issue Nov 5, 2022
@nickgros
Copy link
Contributor

nickgros commented Nov 5, 2022

Fixed in #3229, will be in 5.0.0-beta.13

@nickgros nickgros closed this as completed Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

No branches or pull requests

2 participants