1.0.0 • Published 5 years ago

form-lazy v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

FORML (Form Lazy)

Simple form data validation

Introduction

Installation

# NPM
$ npm install forml --save

# Yarn
$ yarn add forml

Basic Usage

import Forml from 'forml'

const input = {
  firstname: 'John',
  lastname: 'Doe',
  email: 'johnDoe@domain.com'
}

const rules {
  firstname: {
    required: true,
    length: 5,
    custom: (input, error) => {
      if (input === 'John') {
        error.message = 'John is banned from this system'
        return error;
      }
    }
  },
  lastname: {
    required: true,
    legnth: 3,
  },
  email: {
    email: true
  }

}

const hasErrors = Forml.validate(input, rules);

if (hasErrors.length) {
  console.error('We have some errors to resolve ', hasErrors);
}

// Everything is fine ...

Usage

Development

1.0.0

5 years ago