https://github.com/amrdeveloper/validera
NodeJS object validation to check type and value with multi conditions
https://github.com/amrdeveloper/validera
js nodejs nodejs-library validation validera
Last synced: 10 months ago
JSON representation
NodeJS object validation to check type and value with multi conditions
- Host: GitHub
- URL: https://github.com/amrdeveloper/validera
- Owner: AmrDeveloper
- License: mit
- Created: 2020-01-07T17:11:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-06T12:39:33.000Z (about 5 years ago)
- Last Synced: 2025-03-19T12:17:56.677Z (10 months ago)
- Topics: js, nodejs, nodejs-library, validation, validera
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validera
NodeJS object validation to check type and value with multi conditions


## Install
```npm
npm install validera
```
## Usage
```javascript
const validera = require('validera')
```
```javascript
const value = new validera("validera")
.type("string")
.nullOrEmpty()
.valueOrThrow()
```
```javascript
const value = new validera("validera")
.type("string")
.valueOrThrowMessage("It's not string")
```
```javascript
const isValid = new validera(50)
.type("number")
.positive()
.biggerThan(0)
.smallerThan(100)
.check()
```
```javascript
validera.isTypeEqual("validera", "string") //true
validera.isEqualAny(1, [2,3,4]) //false
validera.isNotEqualOneof(1, [2,3,4]) //true
validera.isNotEqualOneof(1, [2,3,4], 5) //true
validera.isNotNull(null) //false
validera.isPositive(1) //true
validera.isNegative(-1) //true
validera.isBiggerThanOneof(9, 1, 11, [5,6]) //true
validera.isBiggerThanAllof(9, 1, 2, [5,6]) //true
validera.isBiggerOrEqualOneof(9, [11, 12, 9]) //true
validera.isSmallerThanOneof(9, [10, 0]) //true
validera.isSmallerThanAllof(9, [10, 11 ,12]) //true
validera.isSmallerOrEqualOneof(9, [1, 2, 9]) //true
validera.isNullorEmpty("") //true
validera.isNullOrZero(null) //true
validera.isZeroOrDefault(0, 10) //10
validera.isNullOrDefault(null, 0) //0
```
If you have an idea or new check to improve Validera you can submit issue or Pull Request.