Skip to content

froncubator/validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Froncubator validator

A simple JavaScript library for validating data. https://github.com/froncubator/validator

Installation and Usage

Install the library with npm install froncubator-validator

const validator = require('froncubator-validator-js');

validator.isInt(123); //=> true
validator.isInt(10.5); //=> false
validator.isInt(undefined); //=> false
validator.isInt(123, 5, 10); //=> false

validator.isStr('Froncubator', 0, 100) //=> true
validator.isStr('Some String', null, 100) //=> true
validator.isStr('Next String', 100) //=> false
validator.isStr(undefined) //=> false

validator.isArr([1,2,3]) //=> true
validator.isArr([1,2,3], 1, 3) //=> true
validator.isArr([1,2,3], 5, 10) //=> false
validator.isArr(null) //=> false

validator.isEmail('some@email.com') //=> true
validator.isEmail('x@x.x') //=> true
validator.isEmail('some@email') //=> false
validator.isEmail('@.') //=> false

validator.isExist(false) //=> true
validator.isExist(undefined) //=> false
validator.isExist(null) //=> false
validator.isExist(NaN) //=> false

Validators list

Validator Description
isEmail(value) Check is value is email and return true or false.
isStr(value, min, max) Check is value is string and return true or false. You can check count of characters in the string with min or max. (min, max) = not required.
isInt(value, min, max) Check is value is integer and return true or false. You can check number with min or max. (min, max) = not required.
isArr(value, min, max) Check is value is array and return true or false. You can check array length with min or max. (min, max) = not required.
isExist(value) Check is value exist (undefined, null, NaN).

Froncubator Validator is freely distributable under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published