factorial-form
TypeScript icon, indicating that this package has built-in type declarations

3.3.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i factorial-form

Weekly Downloads

55

Version

3.3.1

License

MIT

Unpacked Size

44.9 kB

Total Files

13

Last publish

Collaborators

  • masylum
  • fcsonline
  • marctorrelles
  • beagleknight
  • luchhh