Javascript validations and utility library
npm install --save-dev data-validator-js
- Installation and setup
- Usage
- String Utilities
- Script Utilities
- Converter Utilities
- ConvertToCapitals(value: string)
- ConvertToLowerCase(value: string)
- ConvertToCamelCase(value: string)
- ConvertToString(value: number | string | object | null | undefined)
- ConvertToNumber(value: string)
- ConvertToTitleCase(value: string)
- ConvertToLowerCamelCase(value: string)
- ConvertToSnakeCase(value: string)
- ConvertToRandomCase(value: string)
- ConvertToToggleCase(value: string)
- ConvertToSentenceCase(value: string)
npm install --save-dev data-validator-js
import { StringUtilities } from "data-validator-js";
"StringUtilities" has all the validation methods
import { StringUtilities } from "data-validator-js";
let isValidString = StringUtilities.IsNullOrEmpty('test string') // false
isValidString = StringUtilities.IsNullOrEmpty('123') // false
isValidString = StringUtilities.IsNullOrEmpty('') // true
isValidString = StringUtilities.IsNullOrEmpty(' ') // true
isValidString = StringUtilities.IsNullOrEmpty(null) // true
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValidEmail = StringUtilities.IsValidEmail('test string') // false
isValidEmail = StringUtilities.IsValidEmail('123') // false
isValidEmail = StringUtilities.IsValidEmail('') // false
isValidEmail = StringUtilities.IsValidEmail('[email protected]') // true
isValidEmail = StringUtilities.IsValidEmail('[email protected]') // true
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValid = StringUtilities.IsValidString('test string') // true
isValid = StringUtilities.IsValidString('123') // false
isValid = StringUtilities.IsValidString('') // false
isValid = StringUtilities.IsValidString('[email protected]') // false
isValid = StringUtilities.IsValidString('[email protected]') // false
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValidPhoneNumber = StringUtilities.IsValidPhoneNumber('test') // false
isValidPhoneNumber = StringUtilities.IsValidPhoneNumber('123') // false
isValidPhoneNumber = StringUtilities.IsValidPhoneNumber('1234567890') // true
isValidPhoneNumber = StringUtilities.IsValidPhoneNumber('') // false
isValidPhoneNumber = StringUtilities.IsValidPhoneNumber(null) // false
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValid = StringUtilities.IsValidNumber('test') // false
isValid = StringUtilities.IsValidNumber('123') // true
isValid = StringUtilities.IsValidNumber(1235) // true
isValid = StringUtilities.IsValidNumber('ee1234567890') // false
isValid = StringUtilities.IsValidNumber('') // false
isValid = StringUtilities.IsValidNumber(null) // false
#IsValidAlphaNumeric
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValid = StringUtilities.IsValidAlphaNumeric('test') // false
isValid = StringUtilities.IsValidAlphaNumeric('12rf3') // true
isValid = StringUtilities.IsValidAlphaNumeric('4545kk') // true
isValid = StringUtilities.IsValidAlphaNumeric('ee1234567890') // true
isValid = StringUtilities.IsValidAlphaNumeric('') // false
isValid = StringUtilities.IsValidAlphaNumeric(null) // false
import { StringUtilities } from "data-validator-js";
// isValidEmail Validates the given value is valid email format or not
let isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars('test') // false
isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars('12rf3') // false
isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars('4545kk*&') // true
isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars('ee12345$%^6789*0') // true
isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars('3454546') // false
isValid = StringUtilities.IsValidAlphaNumericWithSpecialChars(null) // false
import { ScriptUtilities } from "data-validator-js";
//IsNullOrUndefined checks the obj is null or undefined
let IsValid = ScriptUtilities.IsNullOrUndefined(null) //true
IsValid = ScriptUtilities.IsNullOrUndefined(undefined) //true
IsValid = ScriptUtilities.IsNullOrUndefined({}) //false
IsValid = ScriptUtilities.IsNullOrUndefined({sdsgf:[]}) //false
import { ScriptUtilities } from "data-validator-js";
//IsMacMachine checks the machine, returns true if its a mac machine
let IsValid = ScriptUtilities.IsMacMachine() // if its a mac machine returns true.
import { ScriptUtilities } from "data-validator-js";
//getNumericValue checks and returns a numeric value
let IsValid = ScriptUtilities.getNumericValue('vish') //NaN
IsValid = ScriptUtilities.getNumericValue('123') //123
import { ConverterUtils } from "data-validator-js";
// ConvertToCapitals Converts the given value to UpperCase letters
let Converter = ConverterUtils.ConvertToCapitals('test') // TEST
import { ConverterUtils } from "data-validator-js";
// ConvertToLowerCase Converts the given value to LowerCase letters
let Converter = ConverterUtils.ConvertToLowerCase('TEST')// test
import { ConverterUtils } from "data-validator-js";
// ConvertToCamelCase Converts the given value to CamelCase
let Converter = ConverterUtils.ConvertToCamelCase('test case') // TestCase
import { ConverterUtils } from "data-validator-js";
// ConvertToString Converts the given value to String
let Converter = ConverterUtils.ConvertToString(123) //123
Converter = ConverterUtils.ConvertToString('test') //test
Converter = ConverterUtils.ConvertToString(null) //null
Converter = ConverterUtils.ConvertToString(undefined) //undefined
import { ConverterUtils } from "data-validator-js";
// ConvertToNumber checks the given value is a number or not
let Converter = Converter.ConvertToNumber("123") //123
Converter = Converter.ConvertToNumber("hello") //NaN
import { ConverterUtils } from "data-validator-js";
//ConvertToTitleCase Converts the given value into TitleCase
let Converter = Converter.ConvertToTitleCase('hai hELlo') //Hai Hello
import { ConverterUtils } from "data-validator-js";
// ConvertToLowerCamelCase Converts the given value into LowerCamelCase
let Converter = Converter.ConvertToLowerCamelCase('Hai HeLlo')// haihello
import { ConverterUtils } from "data-validator-js";
//ConvertToSnakeCase Converts the given value into SnakeCase
let Converter = Converter.ConvertToSnakeCase('hello how are you')//hello_how_are_you
import { ConverterUtils } from "data-validator-js";
//ConvertToRandomCase Converts the given value into a random value
let Converter = Converter.ConvertToRandomCase('hello')// changes randomly
import { ConverterUtils } from "data-validator-js";
//ConvertToToggleCase Converts the given value to ToggleCase
let Converter = Converter.ConvertToToggleCase('tEsT')// TeSt
import { ConverterUtils } from "data-validator-js";
//ConvertToSentenceCase converts the given value to SentenceCase
let Converter = Converter.ConvertToSentenceCase('hello Test How are you')//Hello test how are you