Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-validation-map

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-validation-map - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

80

lib/methods.js

@@ -5,3 +5,4 @@ function isRequired(value) {

function isName(value){
function isName(value = undefined){
if( value === undefined) return true;
const regName = new RegExp('^[a-zа-я-]+$', 'i');

@@ -11,3 +12,10 @@ return regName.test(value);

function isEmail(value) {
function isNameWithSpace(value = undefined) {
if( value === undefined) return true;
const regName = new RegExp('^[a-zа-я- ]+$', 'i');
return regName.test(value);
}
function isEmail(value = undefined) {
if( value === undefined) return true;
const regEmail = new RegExp('^[0-9a-z-_\\+.]+\\@([0-9a-z-]{2,}\\.)+[a-z]{2,}$', 'i');

@@ -17,11 +25,63 @@ return regEmail.test(value);

function isInteger(value) {
return Number.isInteger(+value);
function isInteger(value = undefined ) {
if( value === undefined) return true;
return Number(value) === +value && +value % 1 === 0 && value !== '';
}
function isDecimal(value = undefined ) {
if( value === undefined) return true;
console.log('isDecimal', value );
return Number(value) === +value && +value % 1 !== 0 && value !== '';
}
function isRangeNumber(min, max) {
return value => +min <= +value && +max >= +value;
return value => {
if( value === undefined) return true;
return +min <= +value && +max >= +value && value !== '';
}
}
function isPhoneUSA(value = undefined) {
if( value === undefined) return true;
const regPhone = new RegExp('^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$', 'im');
return regPhone.test(value);
}
function isWebsite(value = undefined) {
if( value === undefined) return true;
const regWebsite = new RegExp('^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$', 'gm');
return regWebsite.test(value);
}
function isStreetAddressUSA ( value = undefined) {
if( value === undefined) return true;
const regStreet = new RegExp('^\d+\s[A-z]+\s[A-z]+', 'gi');
return regStreet.test(value);
}
function isZipAddressUSA( value = undefined) {
if( value === undefined) return true;
const regZip = new RegExp('^[0-9]{5}(?:-[0-9]{4})?$', 'gi');
return regZip.test(value);
}
function isStateAddressUSA( value = undefined) {
if( value === undefined) return true;
const regState = new RegExp('([A-Z]{2})', 'g');
return regState.test(value);
}
function isUUID( value = undefined) {
if( value === undefined) return true;
const regUUID = new RegExp('[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}', 'gm');
return regUUID.test(value);
}
module.exports = {

@@ -32,3 +92,11 @@ isRequired,

isName,
isRangeNumber
isNameWithSpace,
isRangeNumber,
isPhoneUSA,
isWebsite,
isStreetAddressUSA,
isZipAddressUSA,
isStateAddressUSA,
isDecimal,
isUUID
}

2

package.json
{
"name": "express-validation-map",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/Valentinishe/express-validation-map",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc