• Stars
    star
    528
  • Rank 81,020 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sophisticated HTML form management for React

react-formal

npm version

Better form validation and value management for React. Provides minimal wiring while also allowing for complete input flexibility.

Built on yup and react-input-message.

Install

npm i -S react-formal yup

(don't like the yup but like how the form works? Try: topeka)

Use

For more complete api documentations, live examples, and getting started guide check out the documentation site.

react-formal uses a yup schema to update and validate form values. It treats the form like an input (representing an object) with a value and onChange. The form can be controlled or uncontrolled as well, just like a normal React input.

var yup = require('yup')
  , Form = require('react-formal')

var modelSchema = yup.object({
        name: yup.object({
            first: yup.string().required('Name is required'),
            last: yup.string().required('Name is required')
        }),
        dateOfBirth: yup.date()
            .max(new Date(), 'You can be born in the future!')
    })

// ...in a component
render() {
    return (
        <Form
            schema={modelSchema}
            value={this.state.model}
            onChange={model => this.setState({ model })}
        >
            <fieldset>
                <legend>Personal Details</legend>

                <Form.Field name='name.first'/>
                <Form.Message for='name.first'/>

                <Form.Field name='name.last'/>
                <Form.Message for='name.last'/>

                <Form.Field name='dateOfBirth'/>
                <Form.Message for='dateOfBirth'/>
            </fieldset>
            <Form.Submit type='submit'>Submit</Form.Submit>
        </Form>
    )
}

More Repositories

1

yup

Dead simple Object schema validation
TypeScript
21,194
star
2

react-big-calendar

gcal/outlook like calendar component
JavaScript
7,418
star
3

react-widgets

Polished, feature rich, accessible form inputs built with React
TypeScript
2,318
star
4

teaspoon

A jQuery like API for testing React elements and rendered components.
JavaScript
388
star
5

react-dom-lite

Tiny dom implementation using react-reconciler
JavaScript
246
star
6

uncontrollable

Wrap a controlled react component, to allow specific prop/handler pairs to be uncontrolled
TypeScript
194
star
7

react-bootstrap-modal

React port of jschr's better bootstrap modals
JavaScript
89
star
8

jarle

Just Another React Live Editor
JavaScript
62
star
9

topeka

Idiomatic, "two-way" bindings, in React.
TypeScript
56
star
10

date-math

simple date math module
JavaScript
53
star
11

bill

css selector engine for React elements and components
JavaScript
53
star
12

react-layer

Simple abstraction for creating and managing new render trees
JavaScript
44
star
13

react-input-message

A small, completely unopinionated way, to display messages next to inputs based on events. Helpful for displaying input validation messages
JavaScript
42
star
14

docusaurus-theme-tailwind

TailwindCSS based Docusaurus theme
TypeScript
27
star
15

webpack-atoms

Small atomic bits for crafting webpack configs
TypeScript
25
star
16

react-component-metadata

JavaScript
21
star
17

expr

tiny util for getting and setting deep object props safely
JavaScript
20
star
18

babel-plugin-jsx-fragment

jsx syntatic sugar for React's `createFragment()`
JavaScript
16
star
19

mp4-info-parser

JavaScript
12
star
20

sass-tailwind-functions

Sass plugin implementing TailwindCSS functions
JavaScript
11
star
21

react-dialog

programtic replacements for Alert and Confirm in React
JavaScript
9
star
22

babel-preset-jason

JavaScript
9
star
23

node-stream-tokenizr

fluent streaming binary parser for working buffer chunks, strings, and byte words
JavaScript
7
star
24

react-formal-inputs

a react-widgets adaptor for react-formal
JavaScript
7
star
25

webpack-config-utils

experiments in webpack config building
JavaScript
7
star
26

babel-preset-env-modules

JavaScript
6
star
27

markdown-jsx-loader

JavaScript
6
star
28

component-metadata-loader

webpack loader to parse React component metadata from source code
JavaScript
5
star
29

mpeg-frame-parser

JavaScript
5
star
30

mini-storybook

no frills story book for components
JavaScript
5
star
31

ogg-info-parser

small streaming .ogg parser for Node.js
JavaScript
5
star
32

tiny-case

JavaScript
4
star
33

vorbis-info-parser

Small parser for Vorbis Bit streams
JavaScript
4
star
34

docpocalypse

TypeScript
4
star
35

css-module-loader

JavaScript
4
star
36

ID3v2-info-parser

ID3 tag version 2 streaming parser
JavaScript
4
star
37

chain-function

chain a bunch of functions
JavaScript
4
star
38

react-clonewithprops

Stand-alone React cloneWithProps util that works with multiple versions of React
JavaScript
3
star
39

vscode-hrx

Syntax Grammar for HRX files
JavaScript
3
star
40

flac-info-parser

JavaScript
3
star
41

node-audio-info

JavaScript
2
star
42

browser-test-pages

2
star
43

react-component-managers

utilities for composing functionality into react-components, alt-mixin
JavaScript
2
star
44

mtag

mp3 Tagging and Batch Altering Scripts
Python
2
star
45

ID3v1-info-parser

JavaScript
2
star
46

scoped-warning

Creates a scoped warning() error for tracking who is throwing what
JavaScript
2
star
47

tiny-set-immediate

Modern polyfill for set immediate
TypeScript
2
star
48

match-resource-repro

JavaScript
2
star
49

react-tackle-box

JavaScript
2
star
50

node-ktc

Pre-compiler for Kendo UI Core templates
JavaScript
2
star
51

asf-info-parser

JavaScript
2
star
52

style-convert-macro

Convert CSS strings to CSS object styles
JavaScript
1
star
53

babel-plugin-external-helpers

insert require for babel helpers
JavaScript
1
star
54

astonish

JavaScript
1
star
55

sound-bytes

JavaScript
1
star
56

oauthenticity

JavaScript
1
star
57

test-publish-actions

JavaScript
1
star
58

cobble

tiny object js object model for doing compositional inheritance
JavaScript
1
star
59

svelte-combobox

Created with CodeSandbox
Svelte
1
star
60

node-simple-chainable

A small node module for queuing a series of functions that follow from each other
JavaScript
1
star
61

kwik-e-mart

pub/sub and datastore
JavaScript
1
star
62

babel-plugin-globalize

Extract formatters and messages from source code
JavaScript
1
star
63

webpack-pitch-repro

JavaScript
1
star