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

Allow field validation using JSON schema #66

Open
jayvdb opened this issue Mar 10, 2022 · 2 comments
Open

Allow field validation using JSON schema #66

jayvdb opened this issue Mar 10, 2022 · 2 comments

Comments

@jayvdb
Copy link

jayvdb commented Mar 10, 2022

Description

I would like to supply a JSON-schema to the widget, and the widget ensures that the field content is validate according to the JSON schema provided.

@KARTHIKEYAN-ACKO
Copy link

KARTHIKEYAN-ACKO commented Nov 3, 2022

You can give that via the options

JSONEditorWidget(
                options={
                 
                    "schema": self.acl_schema,
                }
            )

@Gustutu
Copy link

Gustutu commented Oct 20, 2023

i used it with dynamic json schema stored in a related model. Id dit it by overriding get_form method :

   def get_form(self, request, obj=None, change: bool = False, **kwargs):
        my_form = super().get_form(request, obj, change, **kwargs)
        categorie_spec = Categorie.objects.get(
            id=obj.categorie_id
        ).specifications_schema
        my_form.base_fields["specifications"].widget = JSONEditorWidget(
            options={"schema": categorie_spec}
        )
        return my_form

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

No branches or pull requests

3 participants