veracious

0.0.2 • Public • Published

Veracious

A Javascript validator that tries to be similar to Laravel's.

Installation

Save To Dependencies

npm i veracious --save

Usage

const request = {
  username: 'Chs'
}

const rules = {
  username: 'required|min:1|max:10|alphanum|exists:users,username'
} 

try {
  await Veracious.validate(request, rules, database)
} catch (e) {
  console.log(e)
}

Database Paramater (optional)

The database paramater is optional and is just a plain knex connection. It's used for the unique and exists rules.

let database = Knex({
  client: 'mysql2',
  connection: {
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'habbo'
   }
 })

Error Handling

Errors that are returned will be strings that have a serialized message, ie: [ ERROR ] username does not exist!

Rules

-required
-min:length
-max:length
-unique:table,column
-exists:table,column
-alpha
-alpha_num
-alpha_dash
-numeric

Readme

Keywords

Package Sidebar

Install

npm i veracious

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

8.93 kB

Total Files

6

Last publish

Collaborators

  • chrismpettyjohn