-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Validation Stopped Working After Upgrading (with Disable HTML5 Validation) #4336
Comments
Update: After digging further into the issue and trying to narrow it down, it seems that the described behavior starts occurring from version @rjsf/core@5.1.0 . In all versions prior to that (e.g., 5.0.2), the validation behaves correctly. Reference: the issue was introduced here React JSON Schema Form v5.1.0 Release Notes |
@nok91 Which validator are you using? As far as I can tell, the issue is related to our upgrading from There was probably a bug in By making that field required as shown in this playground, then your error shows up again. |
@heath-freenome I don't believe it's an issue with the validator; it seems to be within the core dependency, @rjsf/core. We've tried using the latest version of @rjsf/validator-ajv8 combined with @rjsf/core@5.0.2, and the validation worked as expected. The issue only arises after upgrading the core to 5.1.0 or above, check the example below: Success case using @rjsf/core@5.0.2 and @rjsf/validator-ajv8@5.22.1: Changing the schema is not a straightforward solution for us, as we've been using this schema since react-jsonschema-form@1.8.1, and it worked fine up to version 5.0.0. It's disappointing that the only way to make it work now is to make changes to the schema. Could you please investigate further? This seems like an issue introduced in the core. Additionally, the documentation does not indicate that the schema requires an outer required property ( https://rjsf-team.github.io/react-jsonschema-form/docs/json-schema/definitions). While your suggestion resolved the issue, it’s unclear why the schema worked fine from versions 1.8.1 to 5.0.0 without this modification |
@heath-freenome Thanks for the quick response. Could you point me to the specific documentation that explains how to properly define the schemas? The only section I found on schema definitions and references is the one referenced below, but the example used doesn't work (please see the playground link above). Is there any plan to update the documentation to include the fix mentioned ? Documentation ref: |
This is what I use https://json-schema.org/understanding-json-schema |
Are you suggesting we update the documentation to look like this playground? Also note that the documentation you specified is just showing how to use |
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
After upgrading from version 5.0.0 to 5.1.0, the form validation stopped functioning as expected, despite using the same schema. Activating the disableHTML5Validation option causes the native validation to not trigger immediately. Is now required to interact with the field before the native validation starts working, which wasn't the case in the previous version.
Expected Behavior
When using the same schema with disableHTML5Validation activated, validation should occur automatically. The form should prevent submission if any required fields are missing, even if the user hasn't interacted with them. This behavior should be consistent with how it worked in version 1.8.1, ensuring a seamless and consistent form validation experience.
Steps To Reproduce
Version 5.0.0
https://codesandbox.io/p/sandbox/j49msr
Version 5.1.0
https://codesandbox.io/p/sandbox/rjsf-5-1-0-2rhpsf
Playground
https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6e30sInNjaGVtYSI6eyJkZWZpbml0aW9ucyI6eyJ1c2VyX3Rva2VuX2dlbmVyYXRpb24iOnsicHJvcGVydGllcyI6eyIxX1BlcHBlciI6eyJkZXNjcmlwdGlvbiI6IlBlcHBlciBmb3IgZ2VuZXJhdGluZyB1c2VyIFVVSURzIGFuZCBlbmNyeXB0aW9uIGtleXMuIFRoaXMgbXVzdCBoYXZlIGEgbWluaW11bSBsZW5ndGggb2YgMTYgY2hhcmFjdGVycy4iLCJtaW5MZW5ndGgiOjE2LCJ0aXRsZSI6IlBlcHBlciBQYXNzd29yZCIsInR5cGUiOiJzdHJpbmcifX0sInJlcXVpcmVkIjpbIjFfUGVwcGVyIl0sInRpdGxlIjoiVXNlciBUb2tlbiBHZW5lcmF0aW9uIiwidHlwZSI6Im9iamVjdCJ9fSwicHJvcGVydGllcyI6eyJVc2VyVG9rZW5HZW5lcmF0aW9uIjp7IiRyZWYiOiIjL2RlZmluaXRpb25zL3VzZXJfdG9rZW5fZ2VuZXJhdGlvbiIsInRpdGxlIjoiVXNlciBUb2tlbiBHZW5lcmF0aW9uMiJ9fSwidHlwZSI6Im9iamVjdCJ9LCJ1aVNjaGVtYSI6eyJSZW1vdGVQZXJzb25hbGlzYXRpb24iOnsiMl9Qcml2aWxlZ2VkUGFzc3dvcmQiOnsidWk6d2lkZ2V0IjoicGFzc3dvcmQifSwiM19VbnByaXZpbGVnZWRQYXNzd29yZCI6eyJ1aTp3aWRnZXQiOiJwYXNzd29yZCJ9LCJQcm94eU5vZGVzIjp7InVpOm9wdGlvbnMiOnsib3JkZXJhYmxlIjpmYWxzZX19fSwiVXNlclRva2VuR2VuZXJhdGlvbiI6eyIxX1BlcHBlciI6eyJ1aTp3aWRnZXQiOiJwYXNzd29yZCJ9fX0sInRoZW1lIjoiZGVmYXVsdCIsImxpdmVTZXR0aW5ncyI6eyJzaG93RXJyb3JMaXN0IjoidG9wIiwidmFsaWRhdGUiOmZhbHNlLCJkaXNhYmxlZCI6ZmFsc2UsIm5vSHRtbDVWYWxpZGF0ZSI6dHJ1ZSwicmVhZG9ubHkiOmZhbHNlLCJvbWl0RXh0cmFEYXRhIjpmYWxzZSwibGl2ZU9taXQiOmZhbHNlLCJleHBlcmltZW50YWxfZGVmYXVsdEZvcm1TdGF0ZUJlaGF2aW9yIjp7ImFycmF5TWluSXRlbXMiOnsiMCI6InAiLCIxIjoibyIsIjIiOiJwIiwiMyI6InUiLCI0IjoibCIsIjUiOiJhIiwiNiI6InQiLCI3IjoiZSIsInBvcHVsYXRlIjoiYWxsIiwibWVyZ2VFeHRyYURlZmF1bHRzIjp0cnVlfSwiYWxsT2YiOiJwb3B1bGF0ZURlZmF1bHRzIiwiZW1wdHlPYmplY3RGaWVsZHMiOiJza2lwRW1wdHlEZWZhdWx0cyJ9LCJmb2N1c09uRmlyc3RFcnJvciI6ZmFsc2UsImxpdmVWYWxpZGF0ZSI6ZmFsc2V9fQ==
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: