Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rjsf/validator-ajv6

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rjsf/validator-ajv6

The ajv-6 based validator for @rjsf/core

  • 5.0.0-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.5K
increased by15.87%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status npm npm downloads Contributors Apache 2.0 License


Logo

@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

Prerequisites

React JsonSchema Form Utils
  • @rjsf/utils >= 5.0.0
yarn add @rjsf/core

Installation

yarn add @rjsf/validator-ajv6

Usage

import Form from '@rjsf/core';
import validator from '@rjsf/validator-ajv6';

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

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

or, using a more complex example using custom validator with custom formats

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 = {
  type: 'string',
  format: 'phone-us'
};

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

or, using a more complex example using a custom with additional meta schema

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 = {
  "$schema": "http://json-schema.org/draft-04/schema#",
  type: 'string',
};

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

Finally, you can combine both additional meta schemas and custom formats.

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,
});

const schema = {
  "$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

Keywords

FAQs

Package last updated on 29 Aug 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc