Minimal library for dealing with form state.
npm install factorial-form --save
yarn add factorial-form
import { Form } from 'factorial-form'
const attributes = {
name: 'paco',
salary: 18000,
created_at: 1497521766937,
metadata: {
friends: 12
}
}
const schema = {
name: 'string',
salary: 'cents',
age: 'timestamp',
metadata: {
friends: 'number'
}
}
const form = new Form(attributes, schema)
const field = form.get('name')
field.value // => 'paco'
form.isDirty // => false
field.set('pepe')
field.value // => 'pepe'
field.isDirty // => true
form.isDirty // => true
Developed and battle tested in production in Factorial