Socket
Socket
Sign inDemoInstall

@rjsf/validator-ajv8

Package Overview
Dependencies
24
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @rjsf/validator-ajv8

The ajv-8 based validator for @rjsf/core


Version published
Weekly downloads
198K
increased by4.49%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

5.7.0

@rjsf/antd

  • Fix #3608 by ensuring the root field is always wrapped in Form.Item
  • Fix #3594 by removing the duplicate title for SelectWidget and description for CheckboxWidget

@rjsf/core

  • Updated the MultiSchemaField to use the new getDiscriminatorFieldFromSchema() API
  • Added new experimental_defaultFormStateBehavior prop to Form
    • to specify alternate behavior when dealing with the rendering of array fields where minItems is set but field is not required (fixes #3363) (#3602)
    • to handle setting object defaults based on the value of emptyObjectFields supporting required fields only and skipping defaults entirely, fixing #2980
  • Fixed regression #3650 in FileWidget to again support adding multiple files to arrays

@rjsf/fluent-ui

  • Added support for additionalProperties to fluent-ui theme, fixing #2777.
  • Upgraded to 8.x version of @fluentui/react maintaining backwards compatibility to version 7, fixing #3463

@rjsf/utils

  • Added two new APIs getDiscriminatorFieldFromSchema() (a refactor of code from MultiSchemaField) and hashForSchema()
    • Updated getDefaultFormState() and toPathSchema() to use getDiscriminatorFieldFromSchema() to provide a discriminator field to getClosestMatchingOption() calls.
  • Refactored the retrieveSchema() internal API functions to support implementing an internal schemaParser() API for use in precompiling schemas, in support of #3543
  • Fixed toPathSchema() to handle properties in an object along with anyOf/oneOf, fixing #3628 and #1628
  • Refactored optional parameters for computeDefaults() into destructured props object to reduce clutter when only specifying later of the optional argument, fixing #3602
  • Fixed computeDefaults() to handle $ref in an object along with anyOf/oneOf, fixing #3633

@rjsf/validator-ajv8

  • Added two new APIs compileSchemaValidators() and createPrecompiledValidator() implemented to support using precompiled validators build with AJV 8, fixing #3543

Dev / docs / playground

  • Added documentation to custom-templates describing how to extend the BaseInputTemplate
  • Added minItems behavior for array field live setting, fixing #3602
  • Upgraded playground to 8.x version of @fluentui/react, fixing #3463
  • Added documentation to validation describing the new precompiled validators feature
  • Added new validator-ajv8.md documentation to the api-reference directory as well as putting it into the sidebar.js

Readme

Source

Build Status npm npm downloads Contributors Apache 2.0 License


Logo

@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
  • @rjsf/utils >= 5.0.0
yarn add @rjsf/core

Installation

yarn add @rjsf/validator-ajv8

Usage

import { RJSFSchema } from 'packages/utils/dist/index';
import Form from 'packages/core/dist/index';
import validator from '@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 '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@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 '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@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 '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@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 '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@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 '@rjsf/utils';
import Form from '@rjsf/core';
import { customizeValidator } from '@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

Keywords

FAQs

Last updated on 13 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc