1.0.2 • Published 2 years ago

@okayitssundar/form-validator v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Installation

npm i --save @sundar/form-validator

or

yarn add @sundar/form-validator

then

import {function} from '@sundar/form-validator'

or
const {function} = require("@sundar/form-validator")

How to use

const {isEmail} = require("@sundar/form-validator")

const email = "hello@email.com"
const notEmail = "hello"

console.log(isEmail(email)) //true
console.log(isEmail(notEmail)) //false

Methods

  • isEmail - check if Email is valid
isEmail("email@email.com") //true
  • max - check if the characters doesn't above the max length
max(character,maxvalue) 
  • min - check if the characters doesn't below the min length
min(character,minvalue) 
  • equalLength - check if the characters is equal to given length
equalLength(character,length) 
  • dataTypeMatch - check if the data type matches
dataTypeMatch(character,datatype) 
  • ValidateExtension - check file type input has valid extension
const options = {
  allowedFiles:[".png",".jpg"],//file extension
  fileID:"imageFile"//id of the input file
}
ValidateExtension(options) 
  • isDate - check if the date is valid
isDate("mm/dd/yyyy") 
  • isUrl - check if the url is valid
isUrl(url) 
  • isTime - check if the time is valid
isTime("23:59") 
  • onlyLetters - return false if the given string contains numbers,symbols,spaces
onlyLetters(string) 
  • letterAndint - return false if the given string contains symbols,spaces
letterAndint(string) 
  • sanitizeSymbols - remove the symbols from the given string
sanitizeSymbols(string)