1.0.2 • Published 1 year ago

easy-form-validation v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Easy Form Validation

Easy Form Validation is a JavaScript Library which makes form validation easy.

The library functions returns a boolean value after validation. The functions can also be customized using an object parameter.

Use Case

You need to validate the inputs.

Installation

You can install this library via NPM

npm install easy-form-validation

Available Validation Methods

FunctionOptional Parameter
validateEmailN/A
validatePasswordAvailable
validateNotEmptyN/A
validateNumberAvailable
validateTextN/A
validateURLN/A

Optional Parameter

The optional parameter is an object which is passed as the 2nd parameter which can be used to customize the validation methods.

Available attributes

validatePassword

{
	minLength: value,
	maxLength: value,
	numbers: false || true, //default false
	characters: false || true, //default true
	specialCharacters: false || true, //default false
	uppercase: false || true, //default false
	lowercase: false || true //default false
}

validateNumber

{
	min: value,
	max: value
}

Importing

ES5

const { validateEmail, validatePassword, validateNotEmpty, validateNumber, validateText, validateURL } = require('easy-form-validation')

ES6

import { validateEmail, validatePassword, validateNotEmpty, validateNumber, validateText, validateURL } from 'easy-form-validation'

Example Usage

ES5

const { validateEmail, validatePassword, validateNotEmpty, validateNumber, validateText, validateURL } = require('easy-form-validation')

console.log(validatePassword('@Abcd1234', {
	minLength:  8,
	numbers:  true,
	specialCharacters:  true,
	uppercase:  true,
	lowercase:  true
})) //returns true

console.log(validatePassword('AAbcd1234', {
	minLength:  8,
	numbers:  true,
	specialCharacters:  true,
	uppercase:  true,
	lowercase:  true
})) //returns false because special character is not presented

ES6

import { validateEmail, validatePassword, validateNotEmpty, validateNumber, validateText, validateURL } from 'easy-form-validation'

console.log(validatePassword('@Abcd1234', {
	minLength:  8,
	numbers:  true,
	specialCharacters:  true,
	uppercase:  true,
	lowercase:  true
})) //returns true

console.log(validatePassword('AAbcd1234', {
	minLength:  8,
	numbers:  true,
	specialCharacters:  true,
	uppercase:  true,
	lowercase:  true
})) //returns false because special character is not presented
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago