Skip to content

Minimal library for dealing with form state.

License

Notifications You must be signed in to change notification settings

factorialco/factorial-form

Repository files navigation

Factorial form

Minimal library for dealing with form state.

Build Status JavaScript Style Guide

Installation

npm install factorial-form --save
yarn add factorial-form

Example

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

Where is it used?

Developed and battle tested in production in Factorial

About

Minimal library for dealing with form state.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published