1.0.4 • Published 3 years ago

@himanoa/schemaless-validator v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

schemaless-validator

A library for quickly and freedom creating validation

import { validate } from '@himanoa/schemaless-validator'

const input = 12

validate((assert) => {
  assert(input > 13, "input must be more than 13")
  assert(input.toString().length > 13, "input must be at least 13 characters")
}).catch(errors => {
  console.dir(errors)
  /*
   * console.dir
   *  [
   *    'input must be more than 13',
   *    'input must be at least 13 characters'
   *  ]
   *
   */
})

Install

npm install @himanoa/schemaless-validator

or

yarn add @himanoa/schemaless-validator

API

validate(validator: (assert: (cond: boolean, exceptMessage: string)) => void): Promise<void>

Execute validator function.

Return the Promise.resolve<void> if error array is empty when after execute validator and return the Promise.resolve(exceptMessageArray) when error is not empty

See. test case

LICENSE

MIT

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago