Comparing version 2.0.3 to 2.0.4
@@ -5,2 +5,3 @@ import Validator from './factory'; | ||
export { default as Validator } from './factory'; | ||
export * from './types'; | ||
export default Validator; |
@@ -1,14 +0,16 @@ | ||
import { ValidationRule } from '../types'; | ||
export declare const isRequired: ValidationRule; | ||
export declare const minLength: (min: number) => ValidationRule; | ||
export declare const maxLength: (max: number) => ValidationRule; | ||
export declare const exactLength: (exact: number) => ValidationRule; | ||
export declare const isPattern: (pattern: string, message?: string | undefined) => ValidationRule; | ||
export declare const isMatch: (pattern: string) => ValidationRule; | ||
export declare const isString: ValidationRule; | ||
export declare const isDigit: ValidationRule; | ||
export declare const isNumeric: ValidationRule; | ||
export declare const isEmail: ValidationRule; | ||
export declare const isUppercase: ValidationRule; | ||
export declare const containsUppercase: ValidationRule; | ||
export declare const containsLowercase: ValidationRule; | ||
declare const _default: { | ||
containsLowercase: import("..").ValidationRule; | ||
containsUppercase: import("..").ValidationRule; | ||
exactLength: (exact: number) => import("..").ValidationRule; | ||
isDigit: import("..").ValidationRule; | ||
isEmail: import("..").ValidationRule; | ||
isMatch: (pattern: string) => import("..").ValidationRule; | ||
isNumeric: import("..").ValidationRule; | ||
isPattern: (pattern: string, message?: string | undefined) => import("..").ValidationRule; | ||
isRequired: import("..").ValidationRule; | ||
isString: import("..").ValidationRule; | ||
isUppercase: import("..").ValidationRule; | ||
maxLength: (max: number) => import("..").ValidationRule; | ||
minLength: (min: number) => import("..").ValidationRule; | ||
}; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _ = require("../helpers/index"); | ||
exports.isRequired = { | ||
runWithValue: (value) => { | ||
if (value === null || value === undefined) | ||
return false; | ||
if (typeof value === 'string') | ||
return _.hasText(value); | ||
return value !== null || value !== undefined; | ||
}, | ||
message: 'This field is required', | ||
const containsLowercase_1 = require("./containsLowercase"); | ||
const containsUppercase_1 = require("./containsUppercase"); | ||
const exactLength_1 = require("./exactLength"); | ||
const isDigit_1 = require("./isDigit"); | ||
const isEmail_1 = require("./isEmail"); | ||
const isMatch_1 = require("./isMatch"); | ||
const isNumeric_1 = require("./isNumeric"); | ||
const isPattern_1 = require("./isPattern"); | ||
const isRequired_1 = require("./isRequired"); | ||
const isString_1 = require("./isString"); | ||
const isUppercase_1 = require("./isUppercase"); | ||
const maxLength_1 = require("./maxLength"); | ||
const minLength_1 = require("./minLength"); | ||
exports.default = { | ||
containsLowercase: containsLowercase_1.default, | ||
containsUppercase: containsUppercase_1.default, | ||
exactLength: exactLength_1.default, | ||
isDigit: isDigit_1.default, | ||
isEmail: isEmail_1.default, | ||
isMatch: isMatch_1.default, | ||
isNumeric: isNumeric_1.default, | ||
isPattern: isPattern_1.default, | ||
isRequired: isRequired_1.default, | ||
isString: isString_1.default, | ||
isUppercase: isUppercase_1.default, | ||
maxLength: maxLength_1.default, | ||
minLength: minLength_1.default, | ||
}; | ||
exports.minLength = (min) => ({ | ||
runWithValue: (value) => { | ||
if (_.hasText(value)) | ||
return value.length >= min; | ||
return false; | ||
}, | ||
message: `Must be at least ${min} long`, | ||
}); | ||
exports.maxLength = (max) => ({ | ||
runWithValue: (value) => { | ||
if (_.hasText(value)) | ||
return value.length <= max; | ||
return false; | ||
}, | ||
message: `Must be at most ${max} long`, | ||
}); | ||
exports.exactLength = (exact) => ({ | ||
runWithValue: (value) => { | ||
if (_.hasText(value)) | ||
return value.length === exact; | ||
return false; | ||
}, | ||
message: `Must be ${exact} long`, | ||
}); | ||
exports.isPattern = (pattern, message) => ({ | ||
runWithValue: (value) => new RegExp(pattern).test(value), | ||
message, | ||
}); | ||
exports.isMatch = (pattern) => ({ | ||
runWithValue(value) { | ||
return new RegExp(pattern).test(value); | ||
}, | ||
}); | ||
exports.isString = exports.isPattern('^[a-zA-Z]+$'); | ||
exports.isDigit = exports.isPattern('^[0-9]+$', 'Invalid number'); | ||
exports.isNumeric = exports.isPattern('^[\\+\\-]?[0-9\\.,]+$', 'Must be numeric'); | ||
exports.isEmail = exports.isPattern('[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}', "That's not an email"); | ||
exports.isUppercase = exports.isPattern('[A-Z\\s]', 'Must be uppercase'); | ||
exports.containsUppercase = exports.isPattern('.*[A-Z]+.*', 'Must contain one uppercase character'); | ||
exports.containsLowercase = exports.isPattern('.*[a-z]+.*', 'Must contain one lowercase character'); |
{ | ||
"name": "validazz", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Magical, Flexible and Extendible Javascript Validation", | ||
@@ -33,2 +33,3 @@ "license": "MIT", | ||
"version": "standard-changelog && git add CHANGELOG.md", | ||
"prepublish": "yarn build", | ||
"postpublish": "git push origin master --follow-tags" | ||
@@ -35,0 +36,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39652
71
863