Package Exports
- @rjsf/validator-ajv6
- @rjsf/validator-ajv6/dist/index.js
- @rjsf/validator-ajv6/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rjsf/validator-ajv6) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@rjsf/validator-ajv6
AJV-6 based validator plugin for react-jsonschema-form.
Explore the docs »
View Playground
·
Report Bug
·
Request Feature
Table of Contents
About The Project
Exports validator-ajv6 plugin for react-jsonschema-form.
Built With
Getting Started
NOTE: This package is deprecated in favor of the
@rjsf/validator-ajv8and is provided primarily for people upgrading to version 5 who initially want to minimize the validator differences.
Prerequisites
React JsonSchema Form Utils
@rjsf/utils >= 5.0.0
yarn add @rjsf/coreInstallation
yarn add @rjsf/validator-ajv6Usage
import { RJSFSchema } from '@rjsf/utils';
import Form from '@rjsf/core';
import validator from '@rjsf/validator-ajv6';
const schema: RJSFSchema = {
type: 'string',
};
<Form schema={schema} validator={validator} />;or, using a more complex example using custom validator with custom formats
import { RJSFSchema } from '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@rjsf/validator-ajv6';
const customFormats = {
'phone-us': /\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
};
const validator = customizeValidator({
customFormats,
});
const schema: RJSFSchema = {
type: 'string',
format: 'phone-us',
};
<Form schema={schema} validator={validator} />;or, using a more complex example using a custom with additional meta schema
import { RJSFSchema } from '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@rjsf/validator-ajv6';
const metaSchemaDraft04 = require('ajv/lib/refs/json-schema-draft-04.json');
const validator = customizeValidator({
additionalMetaSchemas: [metaSchemaDraft04],
});
const schema: RJSFSchema = {
$schema: 'http://json-schema.org/draft-04/schema#',
type: 'string',
};
<Form schema={schema} validator={validator} />;or, using a more complex example using custom validator config override options
import { RJSFSchema } from '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@rjsf/validator-ajv6';
const validator = customizeValidator({
ajvOptionsOverrides: {
$data: true,
verbose: true,
},
});
const schema: RJSFSchema = {
type: 'string',
};
<Form schema={schema} validator={validator} />;Finally, you can combine both additional meta schemas, custom formats and custom validator config override options.
import { RJSFSchema } from '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@rjsf/validator-ajv6';
const metaSchemaDraft04 = require('ajv/lib/refs/json-schema-draft-04.json');
const customFormats = {
'phone-us': /\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
};
const validator = customizeValidator({
additionalMetaSchemas: [metaSchemaDraft04],
customFormats,
ajvOptionsOverrides: {
$data: true,
verbose: true,
},
});
const schema: RJSFSchema = {
$schema: 'http://json-schema.org/draft-04/schema#',
type: 'string',
format: 'phone-us',
};
<Form schema={schema} validator={validator} />;Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Read our contributors' guide to get started.
Contact
rjsf team: https://github.com/orgs/rjsf-team/people
GitHub repository: https://github.com/rjsf-team/react-jsonschema-form