Skip to content

Commit

Permalink
fix: rjsf-team#3110 by deprecating the ajv 6 validator
Browse files Browse the repository at this point in the history
Fix rjsf-team#3110 by deprecating the `@rjsf/validator-ajv6` and improving documentation

- Updated the `README.md` and all files in the `@rjsf/validator-ajv6` as deprecated
- Updated the tests for all themes to switch to using the `@rjsf/validator-ajv8`
  - Due to the changes in messaging syntax with the ajv 8 validator most of the tests that displayed errors needed to be updated
- Updated all of the documentation to be Typescript syntax, switching all examples to `@rjsf/validator-ajv8` with the exception of those few examples specifically for the `@rjsf/validator-ajv6`
- Updated the playground to default to the AJV8 validator and marking the AJV6 validator as deprecated
- Updated the `CHANGELOG.md` accordingly
  • Loading branch information
heath-freenome committed Oct 26, 2022
1 parent cc0ccae commit 7754768
Show file tree
Hide file tree
Showing 69 changed files with 807 additions and 642 deletions.
28 changes: 25 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,32 @@ should change the heading of the (upcoming) version to include a major version b
-->
# 5.0.0-beta.12

## @rjsf/antd
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/bootstrap
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/chakra-ui
- Automatically close single-choice Select widget on selection
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/core
- BREAKING CHANGE: ShowErrorList prop changed to support `false`, `top` or `bottom`; `true` is no longer a valid value as the default changed from `true` to `top` [#634](https://github.com/rjsf-team/react-jsonschema-form/issues/634)
- Added the new generic, `S extends StrictRJSFSchema = RJSFSchema`, for `schema`/`rootSchema` to every component that needed it.
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/fluent-ui
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/material-ui
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/mui
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/semantic-ui
- Updated the tests to use the `@rjsf/validator-ajv8` fixing [#3110](https://github.com/rjsf-team/react-jsonschema-form/issues/3110)

## @rjsf/utils
- Beta-only potentially BREAKING CHANGE: Changed all types that directly or indirectly defined `schema`/`rootSchema` to add the generic `S extends StrictRJSFSchema = RJSFSchema` and use `S` as the type for them.
Expand All @@ -32,15 +52,17 @@ should change the heading of the (upcoming) version to include a major version b

## @rjsf/validator-ajv6
- Fixed a few type casts given the new expanded definition of the `RJSFSchema` type change
- Deprecated this library in favor of the `@rjsf/validator-ajv8`

## @rjsf/validator-ajv8
- Updated the typing to add the new `S extends StrictRJSFSchema = RJSFSchema` generic and fixed up type casts
- Added the `AjvClass` prop to the `CustomValidatorOptionsType` to support using the `Ajv2019` or `Ajv2020` class implementation instead of the default `Ajv` class; fixing [#3189](https://github.com/rjsf-team/react-jsonschema-form/issues/3189)

## Dev / docs / playground
- Updated the `5.x upgrade guide` to document the new `StrictRJSFSchema` and `S` generic
- Updated the `validation` guide to document the new `AjvClass` prop on `CustomValidatorOptionsType`
- Updated the playground to add support for using the AJV 8 validator with the `draft-2019-09` and `draft-2020-12` schemas
- Updated the `5.x upgrade guide` and `utility-functions.md` to document the new `StrictRJSFSchema` and `S` generic
- Updated the `validation` guide to document the new `AjvClass` prop on `CustomValidatorOptionsType` and mentioning the deprecation of `@rjsf/validator-ajv6`
- Updated the playground to add support for using the AJV 8 validator with the `draft-2019-09` and `draft-2020-12` schemas and to make the `AJV8` validator the default validator, marking `AJV6` as deprecated
- Updated all the documentation to switch to Typescript notation where missing along with switching to using the `@rjsf/validator-ajv8` validator as the default

# 5.0.0-beta.11

Expand Down
21 changes: 11 additions & 10 deletions docs/5.x upgrade guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ There are three new packages added in RJSF version 5:

- `@rjsf/utils`: All of the [utility functions](https://react-jsonschema-form.readthedocs.io/en/stable/api-reference/utiltity-functions) previously imported from `@rjsf/core/utils` as well as the Typescript types for RJSF version 5.
- The following new utility functions were added: `createSchemaUtils()`, `getInputProps()`, `mergeValidationData()` and `processSelectValue()`
- `@rjsf/validator-ajv6`: The [ajv](https://github.com/ajv-validator/ajv)-v6-based validator refactored out of `@rjsf/core@4.x`, that implements the `ValidatorType` interface defined in `@rjsf/utils`.
- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v6-based validator refactored out of `@rjsf/core@4.x`, that implements the `ValidatorType` interface defined in `@rjsf/utils`.
- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v8-based validator that is an upgrade of the `@rjsf/validator-ajv8`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. See the ajv 6 to 8 [migration guide](https://ajv.js.org/v6-to-v8-migration.html) for more information.
- `@rjsf/mui`: Previously `@rjsf/material-ui/v5`, now provided as its own theme.
- `@rjsf/validator-ajv8`: The [ajv](https://github.com/ajv-validator/ajv)-v8-based validator that is an upgrade of the `@rjsf/validator-ajv6`, that implements the `ValidatorType` interface defined in `@rjsf/utils`. See the ajv 6 to 8 [migration guide](https://ajv.js.org/v6-to-v8-migration.html) for more information.

### `@rjsf/core` BREAKING CHANGES

Expand Down Expand Up @@ -63,15 +63,16 @@ You can view all these [types](https://github.com/rjsf-team/react-jsonschema-for
#### Form props
In version 5, the `Form` component's two optional props `additionalMetaSchemas` and `customFormats` were replaced with the new, required `validator` prop, in order to support the decoupling of the validation implementation.
This new `validator` prop is expected to be an implementation of the `ValidatorType` interface.
The new `@rjsf/validator-ajv6` package contains the refactored implementation of the version 4 validator.
The new `@rjsf/validator-ajv6` package contains the refactored implementation of the version 4 validator; It was provided for backwards compatibility with RJSF v4, and it is deprecated.
The new `@rjsf/validator-ajv8` package contains the refactored implementation of the version 4 validator, that has been converted to use the `Ajv 8` validator and has more capabilities than the `Ajv 6` one

There are two ways to use this new package to provide a `validator` for a `Form`.
First, you can simply import the default validator from the package and pass it to a `Form`.

```tsx
import { RJSFSchema } from "@rjsf/utils";
import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv6";
import validator from "@rjsf/validator-ajv8";

// Your schema
const schema: RJSFSchema = { ... };
Expand All @@ -86,7 +87,7 @@ Second, if you were actually providing one (or both) of the removed optional pro
```tsx
import { RJSFSchema } from "@rjsf/utils";
import Form from "@rjsf/core";
import { customizeValidator, CustomValidatorOptionsType } from "@rjsf/validator-ajv6";
import { customizeValidator, CustomValidatorOptionsType } from "@rjsf/validator-ajv8";

// Your schema, additionalMetaSchemas and/or customFormats
const schema: RJSFSchema = { ... };
Expand All @@ -107,7 +108,7 @@ As a result, if you were using the `formElement` ref, you will need to update it
```tsx
import { RJSFSchema } from "@rjsf/utils";
import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv6";
import validator from "@rjsf/validator-ajv8";

// Your schema
const schema: RJSFSchema = { ... };
Expand Down Expand Up @@ -136,7 +137,7 @@ If you were previously overriding any (or all) of these components, you can over
```tsx
import { DescriptionFieldProps, RJSFSchema, TitleFieldProps } from "@rjsf/utils";
import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv6";
import validator from "@rjsf/validator-ajv8";

// Your schema
const schema: RJSFSchema = { ... };
Expand Down Expand Up @@ -165,7 +166,7 @@ If you were previously overriding any (or all) of these templates, you can simpl
```tsx
import { ArrayFieldTemplateProps, ErrorListProps, FieldTemplateProps, ObjectFieldTemplateProps, RJSFSchema } from "@rjsf/utils";
import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv6";
import validator from "@rjsf/validator-ajv8";

// Your schema
const schema: RJSFSchema = { ... };
Expand Down Expand Up @@ -200,7 +201,7 @@ If you were previously overriding this component, you can override it now via th
```tsx
import { RJSFSchema, SubmitButtonProps } from "@rjsf/utils";
import Form from "@rjsf/core";
import validator from "@rjsf/validator-ajv6";
import validator from "@rjsf/validator-ajv8";

// Your schema
const schema: RJSFSchema = { ... };
Expand Down Expand Up @@ -263,7 +264,7 @@ function YourWidget(props: WidgetProps) {
```

#### validator.js
Because of the decoupling of validation from `@rjsf/core` this file was refactored into its own `@rjsf/validator-ajv6` package.
Because of the decoupling of validation from `@rjsf/core` this file was refactored into its own `@rjsf/validator-ajv8` package.
During that refactor a few **breaking changes** were made to how it works related to custom validation and `ErrorSchema` conversion.

##### toErrorList param changed
Expand Down
Loading

0 comments on commit 7754768

Please sign in to comment.