input-checker-validator
v1.0.5
Published
This function take input valid all fields with give requirements
Readme
Input validator
This function checks input value and match the given requirements
Installation
Use the package manager npm to install Input check validator.
npm install input-checker-validatorusage
import inputValidator from 'input-checker-validator';
// Yours Input in form of object
const input = {};
// your requirements
// you can enter Array of required feilds,
const requirement = ["username","password"]
// Or Array of object with these feilds
const requirement = ["username",
{
name: "password" //name of feild
required: true, // boolean or string
minLength: 5, // minimum length
maxLength: 10, // maximum length
regex: /^([A-Za-z0-9_\-\.])$/, regex
type: "string" // one of these number, string, boolean, null, undefined, object, symbol
}
]
// Or Object
const requirement = {
defaultRegex:/^([A-Za-z0-9_\-\.])$/, //check on each value required or not
feilds:[ "username",
{
name: "password" //name of feild
required: true, // boolean or string
minLength: 5, // minimum length
maxLength: 10, // maximum length
regex: /^([A-Za-z0-9_\-\.])$/, regex
type: "string" // one of these number, string, boolean, null, undefined, object, symbol
}
]
}
// calling function
const respose = inputValidator({ input, requirement})
// if got error return
{ feild-name: error vaule }
// if no error return null;
License
ISC
