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

How to implement ajv-keywords with rjsf @rjsf/validator-ajvX? #3972

Closed
1 task done
michal-kurz opened this issue Nov 21, 2023 · 2 comments · Fixed by #3991
Closed
1 task done

How to implement ajv-keywords with rjsf @rjsf/validator-ajvX? #3972

michal-kurz opened this issue Nov 21, 2023 · 2 comments · Fixed by #3991
Labels
feature Is a feature request question

Comments

@michal-kurz
Copy link
Contributor

michal-kurz commented Nov 21, 2023

Prerequisites

What theme are you using?

core

What is your question?

I want to use the uniqItemProperties keyword from ajv-keyword library - how can I make this work with @rjsf/validator-ajvX?

I am using ajv-6 validator invoked like this:

import { customizeValidator } from '@rjsf/validator-ajv6'
const validator = customizeValidator({ customFormats: CUSTOM_FORMAT_CRITERIA as any })

The custom keyword should be applied to the ajv instance itself like so:

require('ajv-keywords')(ajv, ['uniqueItemProperties'])

ajv-keyword then calls ajv.addKeyword() on the ajv instance - is there a clean way of applying it with @rjsf/validator-ajv6?

@michal-kurz michal-kurz added needs triage Initial label given, to be assigned correct labels and assigned question labels Nov 21, 2023
@heath-freenome
Copy link
Member

@michal-kurz at the moment we don't expose the internal ajv instance anywhere as we are trying to make validators implementation agnostic. That said, it probably makes sense for us to update our customizeValidator() to expose the underlying ajv instance so that you can do what you need. I'll push a PR with the changes soon

@heath-freenome heath-freenome added feature Is a feature request and removed needs triage Initial label given, to be assigned correct labels and assigned labels Dec 1, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 5, 2023
…on classes

Fixes: rjsf-team#3972 indirectly by exposing the `ajv` variable for use in the issue
- In `@rjsf/ajv6`, updated `AJV6Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
- In `@rjsf/ajv8`, updated `AJV8Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
  - Also removed some `@ts-expect-error` tags that are no longer needed due to the exposed variable
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 5, 2023
…on classes

Fixes: rjsf-team#3972 indirectly by exposing the `ajv` variable for use in the issue
- In `@rjsf/ajv6`, updated `AJV6Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
- In `@rjsf/ajv8`, updated `AJV8Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
  - Also removed some `@ts-expect-error` tags that are no longer needed due to the exposed variable
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this issue Dec 6, 2023
…on classes (#3991)

* Fix: Expose the internal `ajv` variable in the validator implementation classes
Fixes: #3972 indirectly by exposing the `ajv` variable for use in the issue
- In `@rjsf/ajv6`, updated `AJV6Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
- In `@rjsf/ajv8`, updated `AJV8Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
  - Also removed some `@ts-expect-error` tags that are no longer needed due to the exposed variable
- Updated the `CHANGELOG.md` accordingly

* - Responded to reviewer feedback
nickgros added a commit that referenced this issue Dec 8, 2023
Co-authored-by: Jonasz Wiącek <jonaszwiacek@gmail.com>
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Co-authored-by: Bogdan Savluk <savluk.bogdan@gmail.com>
Co-authored-by: Christian Wendt <54559756+cwendtxealth@users.noreply.github.com>
Co-authored-by: Ben Lambert <ben@blam.sh>
Co-authored-by: David R. Bild <david@davidbild.org>
Co-authored-by: Ariqun <38001928+Ariqun@users.noreply.github.com>
fix(utils): direct lodash function import to improve bundling on library client side (#3976)
fix: #3961 resolve all recurse list for object properties (#3981)
fix gap in outline when label is hidden (#3984)
Fix: Expose the internal `ajv` variable in the validator implementation classes (#3991)
Fixes: #3972 indirectly by exposing the `ajv` variable for use in the issue
@michal-kurz
Copy link
Contributor Author

Thank you, @heath-freenome !

Rozamo pushed a commit to Rozamo/react-jsonschema-form that referenced this issue Dec 10, 2023
…on classes (rjsf-team#3991)

* Fix: Expose the internal `ajv` variable in the validator implementation classes
Fixes: rjsf-team#3972 indirectly by exposing the `ajv` variable for use in the issue
- In `@rjsf/ajv6`, updated `AJV6Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
- In `@rjsf/ajv8`, updated `AJV8Validator` to make the `ajv` variable public and changed the return of the `customizeValidator()` function to remove the interface return
  - Also removed some `@ts-expect-error` tags that are no longer needed due to the exposed variable
- Updated the `CHANGELOG.md` accordingly

* - Responded to reviewer feedback
nickgros added a commit that referenced this issue Apr 19, 2024
Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Co-authored-by: Abdallah Al-Soqatri <abdallah.al-soqatri@aspentech.com>
Co-authored-by: Kevin Burnett <18027+burnettk@users.noreply.github.com>
Co-authored-by: Marek Bodinger <marek.bodinger@gmail.com>
Co-authored-by: Mehdi Salem <mehdi.salem@qt.io>
Co-authored-by: Jonasz Wiącek <jonaszwiacek@gmail.com>
Co-authored-by: Bogdan Savluk <savluk.bogdan@gmail.com>
Co-authored-by: Christian Wendt <54559756+cwendtxealth@users.noreply.github.com>
Co-authored-by: Ben Lambert <ben@blam.sh>
Co-authored-by: David R. Bild <david@davidbild.org>
Co-authored-by: Ariqun <38001928+Ariqun@users.noreply.github.com>
Co-authored-by: Shivam Anand Murmu <35562703+Rozamo@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Shubham Biswas <46351104+Shubhcoder@users.noreply.github.com>
Co-authored-by: popmanhe <neo_temp@hotmail.com>
Co-authored-by: Yuki Aoki <me@aoki.app>
Co-authored-by: Xiangcheng Kuo <37873394+orange-guo@users.noreply.github.com>
Co-authored-by: Bart van Andel <bavanandel@gmail.com>
Co-authored-by: Laurent Direr <laurent.direr@gmail.com>
Co-authored-by: Vegard Stenvik <42935080+vstenvik@users.noreply.github.com>
Co-authored-by: Appie <abdallarko@hotmail.com>
Co-authored-by: Oren Forer <oforer@gmail.com>
Co-authored-by: Marcus Penn <11893741+mpenndev@users.noreply.github.com>
Co-authored-by: joachimhagheim <47362824+joachimhagheim@users.noreply.github.com>
Co-authored-by: MarekBodingerBA <104828482+MarekBodingerBA@users.noreply.github.com>
Co-authored-by: momesana <momesana@gmail.com>
Co-authored-by: Martti Roitto <MarttiR@users.noreply.github.com>
fix(utils): direct lodash function import to improve bundling on library client side (#3976)
fix: #3961 resolve all recurse list for object properties (#3981)
fix gap in outline when label is hidden (#3984)
Fix: Expose the internal `ajv` variable in the validator implementation classes (#3991)
Fixes: #3972 indirectly by exposing the `ajv` variable for use in the issue
Fix: Change FormHelperText usage with @mui/material to render divs (#4032)
Fixes #4031 by switching the render component for `FormHelperText` to be `div`
fix: Added support for anyOf/oneOf in uiSchema (#4055)
Fixes #4039 by updating `MultiSchemaField` to properly support `anyOf`/`oneOf` arrays in the `uiSchema`
Fix checkbox with 0 as a value was unselectable in antd (#4068)
Fixed #4067 by properly dealing with enums that have 0 as a value
Fix potential XSS in the preview button of FileWidget (#4065)
Fix: Make 'ui:rows' option work with chakra-ui for textarea elements #4070 (#4078)
Fix typo in ErrorsListTemplate example (#4087)
Fix #4080 by moving `base64` encoder/decoder from `@rjsf/utils` to playground (#4093)
Fix: Error state not resetting when schema changes (#4079) (#4103)
Fix noImplicitAny error (#4106)
Fixes: [WARNING] Duplicate key "include" in object literal [duplicate-object-key] (#4114)
Fixes: Warning: validateDOMNesting(...): <p> cannot appear as a descendant of <p>. (#4117)
Fix documentation to add missing Form imports (#4131)
Fix #4127 to add missing `Form` import in documentation
Fix: filename should be bold (#4125)
Fix: use correct ConfigProvider context by using named imports (#4132)
Fix 4134 by filtering out bad DOM props (#4140)
Fixes: #4134 by updating the spreading of props onto the `TextField` to remove bad DOM fields
Fixed Programmatic submit not working properly in Firefox (#4150)
Fix Maximum call stack size exceeded in findSchemaDefinition (#4123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is a feature request question
Projects
None yet
2 participants