JSPM

@snups/rjsf-validator-ajv8

6.0.0-beta.15.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q58714F
  • License Apache-2.0

The ajv-8 based validator for @snups/rjsf-core

Package Exports

  • @snups/rjsf-validator-ajv8
  • @snups/rjsf-validator-ajv8/compileSchemaValidators
  • @snups/rjsf-validator-ajv8/dist
  • @snups/rjsf-validator-ajv8/dist/compileSchemaValidators
  • @snups/rjsf-validator-ajv8/dist/compileSchemaValidators.esm.js
  • @snups/rjsf-validator-ajv8/dist/compileSchemaValidators.js
  • @snups/rjsf-validator-ajv8/dist/compileSchemaValidatorsCode.js
  • @snups/rjsf-validator-ajv8/dist/createAjvInstance.js
  • @snups/rjsf-validator-ajv8/dist/createPrecompiledValidator.js
  • @snups/rjsf-validator-ajv8/dist/customizeValidator.js
  • @snups/rjsf-validator-ajv8/dist/index.js
  • @snups/rjsf-validator-ajv8/dist/precompiledValidator.js
  • @snups/rjsf-validator-ajv8/dist/processRawValidationErrors.js
  • @snups/rjsf-validator-ajv8/dist/types.js
  • @snups/rjsf-validator-ajv8/dist/validator-ajv8.esm.js
  • @snups/rjsf-validator-ajv8/dist/validator-ajv8.umd.js
  • @snups/rjsf-validator-ajv8/dist/validator.js
  • @snups/rjsf-validator-ajv8/lib
  • @snups/rjsf-validator-ajv8/lib/compileSchemaValidators
  • @snups/rjsf-validator-ajv8/lib/compileSchemaValidators.esm.js
  • @snups/rjsf-validator-ajv8/lib/compileSchemaValidators.js
  • @snups/rjsf-validator-ajv8/lib/compileSchemaValidatorsCode.js
  • @snups/rjsf-validator-ajv8/lib/createAjvInstance.js
  • @snups/rjsf-validator-ajv8/lib/createPrecompiledValidator.js
  • @snups/rjsf-validator-ajv8/lib/customizeValidator.js
  • @snups/rjsf-validator-ajv8/lib/index.js
  • @snups/rjsf-validator-ajv8/lib/precompiledValidator.js
  • @snups/rjsf-validator-ajv8/lib/processRawValidationErrors.js
  • @snups/rjsf-validator-ajv8/lib/types.js
  • @snups/rjsf-validator-ajv8/lib/validator-ajv8.esm.js
  • @snups/rjsf-validator-ajv8/lib/validator-ajv8.umd.js
  • @snups/rjsf-validator-ajv8/lib/validator.js

Readme

Build Status npm npm downloads Contributors Apache 2.0 License


Logo

@snups/rjsf-validator-ajv8 (fork of @rjsf/validator-ajv8)

AJV-8 based validator plugin for react-jsonschema-form.
Explore the docs »

View Playground · Report Bug · Request Feature

Table of Contents

About The Project

Exports validator-ajv8 plugin for react-jsonschema-form.

Built With

Getting Started

Prerequisites

React JsonSchema Form Utils

  • @snups/rjsf-utils >= 5.0.0
yarn add @snups/rjsf-core

Installation

yarn add @snups/rjsf-validator-ajv8

Usage

import { RJSFSchema } from 'packages/utils/dist/index';
import Form from 'packages/core/dist/index';
import validator from '@snups/rjsf-validator-ajv8';

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 '@snups/rjsf-utils';
import Form from '@snups/rjsf-core';
import { customizeValidator } from '@snups/rjsf-validator-ajv8';

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 '@snups/rjsf-utils';
import Form from '@snups/rjsf-core';
import { customizeValidator } from '@snups/rjsf-validator-ajv8';

const metaSchemaDraft06 = require('ajv/lib/refs/json-schema-draft-06.json');

const validator = customizeValidator({
  additionalMetaSchemas: [metaSchemaDraft06],
});

const schema: RJSFSchema = {
  $schema: 'http://json-schema.org/draft-06/schema#',
  type: 'string',
};

<Form schema={schema} validator={validator} />;

or, using a more complex example using custom validator config override options

import { RJSFSchema } from '@snups/rjsf-utils';
import Form from '@snups/rjsf-core';
import { customizeValidator } from '@snups/rjsf-validator-ajv8';

const validator = customizeValidator({
  ajvOptionsOverrides: {
    $data: true,
    verbose: true,
  },
});

const schema: RJSFSchema = {
  type: 'string',
};

<Form schema={schema} validator={validator} />;

or, using a more complex example using ajv-formats custom format options.

import { RJSFSchema } from '@snups/rjsf-utils';
import Form from '@snups/rjsf-core';
import { customizeValidator } from '@snups/rjsf-validator-ajv8';

const validator = customizeValidator({
  ajvFormatOptions: {
    keywords: true,
    formats: ['date', 'time'],
  },
});

const schema: RJSFSchema = {
  type: 'string',
};

<Form schema={schema} validator={validator} />;

Finally, you can combine both additional meta schemas, custom formats, custom validator config override options and ajv-formats custom format options.

import { RJSFSchema } from '@snups/rjsf-utils';
import Form from '@snups/rjsf-core';
import { customizeValidator } from '@snups/rjsf-validator-ajv8';

const metaSchemaDraft06 = require('ajv/lib/refs/json-schema-draft-06.json');

const customFormats = {
  'phone-us': /\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$/,
};

const validator = customizeValidator({
  additionalMetaSchemas: [metaSchemaDraft06],
  customFormats,
  ajvOptionsOverrides: {
    $data: true,
    verbose: true,
  },
  ajvFormatOptions: {
    keywords: true,
    formats: ['date', 'time'],
  },
});

const schema: RJSFSchema = {
  $schema: 'http://json-schema.org/draft-06/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