-
Notifications
You must be signed in to change notification settings - Fork 22
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
Support RJSF Schema validation in strict CSP #3059
Comments
What do you intend to do here? Should we move RJSF to the sandbox or do you want to propose changes upstream? You had mentioned
I'm asking because some code may not currently allow asynchronous function calls and may need refactoring. |
Looks like the RJSF team has a v5 in beta that modularized the validation code. In v4 what we have to deal with is:
In v5, it looks like validation is still not async though 😞 : https://github.com/rjsf-team/react-jsonschema-form/blob/main/packages/validator-ajv6/src/validator.ts#L256 So I think our current bet is to look into using extraErrors. For v4 we also may need to use webpack so swap out some internal implementations |
Do you have something in mind with regards to async code? What I'm asking is about |
I see us as having two options:
I have no clue what the functional difference between what @cfworker/json-schema can validate vs. Ajv. I suspect that @cfworker/json-schema is sufficient for our field types in the Form Builder. The only gotcha would be if we need to translate the validation exceptions from @cfworker/json-schema to the format RJSF expects from Ajv Any thoughts on what might be path of least resistance? |
I haven’t looked into either dependency yet, but I think that making changes to our own engine is quicker than dealing with upstream PRs and error translation issues that might crop up over time.
The ideal solution might be to send a PR to RJSF but the level of effort, lobbying and time is probably high. |
A PR to introduce @cfworker/json-schema support, or a PR to introduce async validation support? Async validation support might already be supported enough for what we need: rjsf-team/react-jsonschema-form#1444 They'd potentially accept a PR to introduce
I think we'd definitely try to use the
To my knowledge we aren't. I also poked around and don't see any places. The only place I could see us using it in the future, is for validating configuration vs. the integration definition schema for assist with debugging. For that we could definitely use @cfworker/json-schema |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I'm learning about this as we go, so further questions may be best discussed with someone more familiar with validation. In the meantime I opened an issue upstream. Here's my current thought with our 4 options (pick one): v4
v5
|
Let's not let this block the Sandbox work for Nunjucks, etc. I think for Option 2 you meant to say "use @cfworker/json-schema" via webpack. Given the the stability of RJSF v4 (because of the impending v5 release), I suspect dependency updates wouldn't be a problem The next step is to see how close |
Yes 😅 👍 |
It seems that we don't have any Jest tests around this component so iterating on a webpack-based replacement might be slow. Given that RJSF authors seem open to the idea of a
|
I think it's work spending an hour seeing what would be involved in that. I suspect it won't be a major lift given that Once we have a v5 plugin PR, we can in parallel:
However, let's get Nunjucks into the Sandbox prior to doing RJSF work
🤦 We'll want to address that. I suspect it's due to the iframe/communication. We have an SDET Intern starting early Jan. That could b a good component for them to look at the mocking of |
Edit: I don’t think so. Is this relevant to us? That PR closed this issue: However I don’t think we can pre-compile the schemas outside the extension… or can we? Maybe pre-compile them in the sandbox and then use them synchronously via ajv8: Example: <CompileSchema schema={schema}>
{compiledSchema => <JsonSchemaForm schema={compiledSchema}/>}
</CompileSchema> This might be easier than replacing the validator: |
On further review, that probably won't work. The compilation isn't the issue, it's the validation that can't run in the content script.
If async validation was possible, this would be a useful API, but RJSF does not support that. |
* [WIP]: switch form validator to cfworker * Default to draft 7 * update package-lock * wip * wip * wip * code cleanup * more code cleanup * unskips remaining tests * fixes schema is not extensible issue * cloneDeep schema for other RJSF forms * Update src/bricks/transformers/ephemeralForm/EphemeralForm.tsx Co-authored-by: Ben Loe <below413@gmail.com> * Update src/components/formBuilder/preview/FormPreview.tsx Co-authored-by: Ben Loe <below413@gmail.com> * remove unnecessary comments * removes unused method args * removes unnecessary comments --------- Co-authored-by: Graham Langford <grahamlangford87@gmail.com> Co-authored-by: Graham Langford <30706330+grahamlangford@users.noreply.github.com> Co-authored-by: Ben Loe <below413@gmail.com>
Context:
The text was updated successfully, but these errors were encountered: