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 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-form-auto

v1.1.9

Published

Automatic validation and generation of forms for redux-form

Downloads

30

Readme

Build Status

redux-form-auto

This library allows your React application to automatically generate forms and validation code using ReduxForm for state management. The form and validations are generated following a schema inspired by SimpleSchema.

At the moment the skins available are:

More skins will be added. Join me!

Project status

This is more or less abandonware. I will probably update for security concerns. Anyway, if you have a need, try to open an issue. If it's easy I may do it. And of course, PRs are welcome.

Play with a demo

Migration from 1.0.x

The library doesn't include bootstrap 3 styles by default any more. If you want to use bootstrap 3 skin you have to include its npm, see installation.

Installation

Choose the skin and import the corresponding package

$ npm install redux-form-auto-bootstrap3 --save

Current skins:

  • redux-form-auto-bootstrap3
  • redux-form-auto-bootstrap4
  • redux-form-auto-antd

Usage

1. Write schema

Write a schema for each model you have:

    import { Schema } from 'redux-form-auto-bootstrap3'
    // ... or ...
    import { Schema } from 'redux-form-auto-bootstrap4'
    // ... or ...
    import { Schema } from 'redux-form-auto-antd'

    export const client = new Schema('client', {
      name: {
        type: 'string',
        required: true,
        max: 32
      },
      age: {
        type: 'number'
      }
    })

Here we are saying that a client is required to have a name and providing its allowed length. Also client has age and it's a number.

Here you can find the complete list of types and validators available.

2. Render a form

<Autoform /> React component will generate connected inputs including translatable label, proper input types and error/warning messages:

    import { Autoform } from 'redux-from-auto-<skin>'
    import { client } from './models/client'

    const MyForm = ({ onSubmit }) =>
      <Autoform
        schema={client}
        onSubmit={onSubmit}
      />

Form will be validated following the rules set in the schema, beginning with the type itself.

It also allows you to build arrays from other schemas as ReduxForm's FieldArray. You just toss an array with another schema from elsewhere as first element and Autoform will allow you to add and remove elements:

    import { Schema } from 'redux-form-auto-<skin>'
    import { client } from './client'

    export const company = new Schema('company', {
      clients: {
        type: [client],
        minChildren: 10
      }
    })

Read the documentation to find out what else you can do:

Documentation

You can also take the demo project as an example of use.

Rationale

One of the purposes of the library is to avoid repeating code by not having to write a set of input components for every entity. Also when time is of the essence, writing forms can be exasperating.

These are some of the advantages of using an automatic form system.

Also redux-form-auto has some of its own

  • Validation is also automatic
  • Includes a translation system
  • It's easily expandable
  • It's simple
  • When possible tries to use convention over configuration

Help wanted

Let's have some fun automatizing the hell out of every UI library out there. Join me!