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

Bump/ajv #2542

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/4.x upgrade guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 4.x Upgrade Guide

## Breaking changes

### Breaking changes due to Ajv v7

The following is a list of changes due to Ajv update to v7.

#### JSON Schema draft-04

This version drops support for JSON schema draft-04.
You can update your schema to the specs of draft-07 using [ajv-cli](https://www.npmjs.com/package/ajv-cli).

#### Object property name restrictions

The following characters may cause unexpected behavior when used in property names:
- /
- [
- ]

If you are using any of these in your property names, you should change them or continue using 3.x until EOL.

## New

### Schema warnings

If your schema does not pass the strict types check, you will see warnings printed to stderr/console. Your form will work as expected even with the warnings. You should aim to fix the schema to avoid the warnings as these schemas will not be accepted in the next major version.
2 changes: 1 addition & 1 deletion docs/api-reference/form-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Note that this just renders the `action` attribute in the HTML markup. There is

## additionalMetaSchemas

This prop allows you to validate the form data against another JSON Schema meta schema, for example, JSON Schema draft-04. See [Validation](../usage/validation.md) for more information.
This prop allows you to validate the form data against another JSON Schema meta schema, for example, JSON Schema draft-06. See [Validation](../usage/validation.md) for more information.

## ArrayFieldTemplate

Expand Down
12 changes: 6 additions & 6 deletions docs/usage/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ To have your schemas validated against any other meta schema than draft-07 (the

```json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-06/schema#",
...
}
```
Expand All @@ -186,22 +186,22 @@ Note that react-jsonschema-form only supports the latest version of JSON Schema,

### additionalMetaSchemas

The `additionalMetaSchemas` prop allows you to validate the form data against one (or more than one) JSON Schema meta schema, for example, JSON Schema draft-04. You can import a meta schema as follows:
The `additionalMetaSchemas` prop allows you to validate the form data against one (or more than one) JSON Schema meta schema, for example, JSON Schema draft-06. You can import a meta schema as follows:

```jsx
const metaSchemaDraft04 = require("ajv/lib/refs/json-schema-draft-04.json");
const metaSchemaDraft06 = require("ajv/lib/refs/json-schema-draft-06.json");
```

In this example `schema` passed as props to `Form` component can be validated against draft-07 (default) and by draft-04 (added), depending on the value of `$schema` attribute.
In this example `schema` passed as props to `Form` component can be validated against draft-07 (default) and by draft-06 (added), depending on the value of `$schema` attribute.

```jsx
const schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-06/schema#",
type: "string"
};

return (<Form schema={schema}
additionalMetaSchemas={[metaSchemaDraft04]} />);
additionalMetaSchemas={[metaSchemaDraft06]} />);
```

## customFormats
Expand Down
Loading