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

Add IFormValidator #13927

Closed
wants to merge 6 commits into from
Closed

Conversation

bollwyvl
Copy link
Contributor

@bollwyvl bollwyvl commented Feb 5, 2023

References

Elevator Pitch

This starts the process of making the JupyterLab's JSON Schema validator replaceable.

Motivation

The choice of underlying validator library is now inextricably (but correctly) linked to the visual presentation of settings and notebook metadata.

Being able to swap to another, as-of-yet unspecified validator, is ultimately to avoid breakage when JupyterLab is hosted with the unsafe-eval CSP set (this can be done, e.g. by portal iframes, over which the application deployer and consumer may have no control). Choosing a validator is out of scope, and discussed in the Future Work session below

And yes, all of this is a little silly when the user controls the application. But here we are.

Code changes

  • add a new package, @jupyterlab/validator-ajv8-extension
    • add a plugin @jupyterlab/validator-ajv8-extension:form-validator
      • the definition of IFormValidator stays in @jupyterlab/ui-components
    • consolidates imports of @rjsf/validator-ajv8 into a single async import
      • ...except one test

User-facing changes

Backwards-incompatible changes

Future Work

On a follow-on PR:

  • add a new package, @jupyterlab/validator
    • consolidate all imports of ajv
    • move ISchemaValidator here
    • expand typings to offer concepts like
      • known schema
      • extra keywords
    • make a dependent of ISettingsRegistry
  • refactor settings to not rely on the Schema validator to calculate the composite from defaults
    • this is not supported by any implementation i could find

  • add a ISchemaValidator provider to @jupyterlab/validator-ajv8-extension

Even if that were done, there would be more work to address the use of eval in a number other known places in this codebase and dependencies.

Of those, probably only pageconfig is "critical," difficult to replace functionality, while the others could probably be worked around.

@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@bollwyvl
Copy link
Contributor Author

This PR has bitrotted, unlikely to continue this work at this time.

@bollwyvl bollwyvl closed this Apr 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant