0.0.3 • Published 2 years ago

proy v0.0.3

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

Proy

A streamlined form validation library

Quick Start

$ yarn add proy

$ npm install proy

Usage

import { proy } from 'proy'

const descriptor = {
  name: {
    type: 'string',
    required: true,
    validator: (rule, val) => val === 'kanno',
  },
}

const basic = proy(descriptor)

basic.validate({ name: 'XeryYue' }, (err, fields) => {
  if (err) {
    errHandelr(err)
  }
})

API

Validate

function(source,(err,fields)):void
  • source : The object to validate (required).

  • callback: A callback function to invoke when validation completes .The callback will return a sync function

  • err: A error list

  • fields: A list of successfully verified data

descriptor

function(descriptor):Proy
  • descriptor : entry your validate rule
interface Rule {
  type: 'string' | 'number' | 'boolean' | 'array' | 'object';
  required?: boolean;
  validate?: (val: any) => boolean;
}

Procude

  • produce will interrupt the chain call.
  • produce will return successfully verified data , If un verifeid will return empty object .

LICENSE

MIT