npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

redux-form-with-ajv

v1.1.0

Published

validate your redux forms with ajv (json-schema)

Readme

Travis npm

redux-form-with-ajv

This package combines redux-form with json-schema. It transforms the generated ajv errors to a way that redux-form can work with. As validation library it uses ajv.

The advanced usage give you more control about ajv itself, so you can pass your own instance of ajv maybe with plugins like ajv-errors, ajv-keywords, ajv-i18n (must be passed by localize option) and so on, as well you have full control about the error via a callback.

Installation

npm install --save redux-form-with-ajv

Basic usage

import validate from 'redux-form-with-ajv';

export default reduxForm({
  form: 'yourForm',
  validate: validate(yourJsonSchema)
})(YourForm);

Advanced usage: options

Use your custom ajv instance via ajv option

You can use ajv option when you need full control of ajv. It is only mandatory to pass two options, allErrors and verbose.

import Ajv from 'ajv';
import validate from 'redux-form-with-ajv';

// Be sure to set the mandatory options!
const ajv = new Ajv({
  allErrors: true,
  verbose: true
});

export default reduxForm({
  form: 'yourForm',
  validate: validate(yourJsonSchema, { ajv })
})(YourForm);

Localize error message via localize option with ajv-i18n

You can use localize option to pass the translations from ajv-i18n.

import localize from 'ajv-i18n';
import validate from 'redux-form-with-ajv';

export default reduxForm({
  form: 'yourForm',
  validate: validate(yourJsonSchema, { localize: localize.sv })
})(YourForm);

Customize error message via errorMessage option

You can use errorMessage option to pass a function that will receive an ajv error object as argument and should return error message.

import validate from 'redux-form-with-ajv';

const errorMessage = error => {
  if (error.keyword === 'required') {
    return 'is required';
  }

  return error.message;
};

export default reduxForm({
  form: 'yourForm',
  validate: validate(yourJsonSchema, { errorMessage })
})(YourForm);

View Sandbox Samples

Simple validation with few Field(s)

Dynamic validation with FieldArrays and custom error messages