NeXTSTEP Programming Mastermind

    validera

    1.0.1 • Public • Published

    Validera

    NodeJS object validation to check type and value with multi conditions

    Install

    npm install validera
    

    Usage

    const validera = require('validera')
    const value = new validera("validera")
            .type("string")
            .nullOrEmpty()
            .valueOrThrow()
    const value = new validera("validera")
            .type("string")
            .valueOrThrowMessage("It's not string")
    const isValid = new validera(50)
            .type("number")
            .positive()
            .biggerThan(0)
            .smallerThan(100)
            .check()   
    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.

    Install

    npm i validera

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    15.7 kB

    Total Files

    5

    Last publish

    Collaborators

    • amrdeveloper