Nantes Paradox Market

    @rocklab/validation
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.32 • Public • Published

    Rocklab validators

    Node CI

    A library for input validation

    • Credit card (number, cvc, expiration date)
    • BIC (Bank Identifier Code)
    • E-mail address
    • IBAN (International Bank Account Number)
    • non empty
    • length
    • password
    • username

    Requirements

    • node version 14
    • npm version 6

    Install

    npm install @rocklab/validation

    Usage

    Validate input:

    import { isEmail, hasLength } from '@rocklab/validation';
    
    if (!isEmail(value)) {
      alert('Please enter a valid email address');
    }
    
    if (!hasLength(value, { min: 3, max: 10 })) {
      alert('3-8 chars required');
    }

    Apply multiple validators:

    import { validate, Validators } from '@rocklab/validation';
    
    const errors = validate(value, [
    	{ validator: Validator.NotEmpty, message: 'Input required'},
      { validator: Validator.Email, message: 'email required'},
    ]);

    Development

    Setup

    git clone https://github.com/cstn/rocklab-validation.git
    npm install

    Commands

    Build

    npm run build

    Check code conventions

    npm run lint
    npm run lint:fix

    Auto format code

    npm run prettier

    Run tests

    npm test
    npm run watch

    WITHOUT WARRANTY OF ANY KIND

    Install

    npm i @rocklab/validation

    DownloadsWeekly Downloads

    59

    Version

    2.0.32

    License

    MIT

    Unpacked Size

    120 kB

    Total Files

    99

    Last publish

    Collaborators

    • cstn