form-lazy

1.0.0 • Public • Published

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

/form-lazy/

    Package Sidebar

    Install

    npm i form-lazy

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    77.4 kB

    Total Files

    23

    Last publish

    Collaborators

    • bdryanovski