2.1.0 • Published 2 years ago

@rocklab/validation v2.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years 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

2 years ago

2.0.71

2 years ago

2.1.0

2 years ago

2.0.32

3 years ago

2.0.41

3 years ago

2.0.30

3 years ago

2.0.27

3 years ago

2.0.19

3 years ago

2.0.20

3 years ago

2.0.21

3 years ago

2.0.17

3 years ago

2.0.16

3 years ago

2.0.3

3 years ago

2.0.13

3 years ago

2.0.5

3 years ago

2.0.12

3 years ago

2.0.6

3 years ago

2.0.9

3 years ago

2.0.0

3 years ago

1.0.0

4 years ago

1.0.5

3 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

5 years ago

0.4.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

6 years ago

0.1.0

6 years ago