validation-x
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

validation-x

npm package npm-bundle-size Module formats npm-download-count

Simple chain validator for string, number, date input

String Validation

Options

Name Type Description
string func(errorMessage:string) Type check
required func(errorMessage:string) isEmpty check
len func(val: number, errorMessage:string) Exact length check for input
min func(val: number, errorMessage:string) Min length for input
max func(val: number, errorMessage:string) Max length for input
matches func(val: number, errorMessage:string) regex check
email func(errorMessage:string) Email check with (/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/)
url func(errorMessage:string) URL check with (/((([A-Za-z]{3,9}:(?://)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+
lowercase func(errorMessage:string) lowercase check
uppercase func(errorMessage:string) uppercase check
custom func(func, errorMessage:string) check with provided custom function

Number Validation

Options

Name Type Description
number func(errorMessage:string) Type check
min func(val: number, errorMessage:string) Min for input
max func(val: number, errorMessage:string) Max for input
positive func(errorMessage:string) If input is positive number
negative func(errorMessage:string) If input is negative number
matches func(val: number, errorMessage:string) regex check
custom func(func, errorMessage:string) check with provided custom function

Date Validation

Options

Name Type Description
min func(val: Date, errorMessage:string) Min for input
max func(val: Date, errorMessage:string) Max for input

License

This project is licensed under the MIT License - see the LICENCE.md file for details

Package Sidebar

Install

npm i validation-x

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

18.5 kB

Total Files

15

Last publish

Collaborators

  • kaansey