A simple forms manager for react.
npm install @alekna/react-formsBuild forms from array of field objects and stream errors from generator
[![size][size-badge]][unpkg-lib]
[![gzip size][gzip-badge]][unpkg-lib]
npm i @alekna/react-forms
``jsx
import React from 'react';
import { render } from 'react-dom';
import { Form } from '@alekna/react-forms';
const mustContainLetter = letter => value => {
return !value.includes(letter) ? Must contain letter ${letter} : undefined;
};
const initialFields = [
{
value: '',
label: 'First Name',
name: 'firstName',
type: 'text',
requirements: [
mustContainLetter('a'),
mustContainLetter('b'),
mustContainLetter('c'),
],
},
{
value: '',
label: 'Last Name',
name: 'lastName',
type: 'text',
requirements: [],
},
];
render(
[gzip-badge]: http://img.badgesize.io/https://unpkg.com/downshift/dist/downshift.umd.min.js?compression=gzip&label=gzip%20size&style=flat-square
[size-badge]: http://img.badgesize.io/https://unpkg.com/downshift/dist/downshift.umd.min.js?label=size&style=flat-square
[unpkg-lib]: https://unpkg.com/@alekna/react-forms@1.0.5/lib