2.1.0 • Published 8 months ago

@rocklab/validation v2.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 months ago

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 18
  • npm version 9

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

2.0.78

9 months ago

2.0.71

10 months ago

2.1.0

8 months ago

2.0.32

2 years ago

2.0.41

2 years ago

2.0.30

2 years ago

2.0.27

2 years ago

2.0.19

2 years ago

2.0.20

2 years ago

2.0.21

2 years ago

2.0.17

2 years ago

2.0.16

2 years ago

2.0.3

2 years ago

2.0.13

2 years ago

2.0.5

2 years ago

2.0.12

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

1.0.5

2 years ago

0.5.3

2 years ago

0.5.2

3 years ago

0.5.1

4 years ago

0.4.0

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago