validate-promise
Advanced tools
Comparing version 3.5.3 to 3.6.0
@@ -1,1 +0,1 @@ | ||
{"processes":{"01a7c142-155c-4473-850c-40cb138a80a7":{"parent":null,"children":[]},"0f9ffb18-93b7-4d9e-9f14-d2202b0ed480":{"parent":null,"children":["836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"]},"836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0":{"parent":"0f9ffb18-93b7-4d9e-9f14-d2202b0ed480","children":[]}},"files":{"/Users/anna/Development/validate-promise/src/index.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/after.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/atleastOneRequired.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/before.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/blacklist.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/domain.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/email.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/equals.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/equalto.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/float.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/greaterthan.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/int.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/isUploaded.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/lessthan.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/notEquals.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/regex.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/required.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/url.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"],"/Users/anna/Development/validate-promise/src/rules/whitelist.ts":["01a7c142-155c-4473-850c-40cb138a80a7","836bf0d7-d0b9-4d48-bdf0-dcb7bd75b6c0"]},"externalIds":{}} | ||
{"processes":{"37c2060c-da1f-4c3b-9912-ab7023c875b8":{"parent":null,"children":[]},"c18a4a4f-c934-4c5c-a9d1-cba3ffe72f00":{"parent":null,"children":[]}},"files":{},"externalIds":{}} |
@@ -19,2 +19,4 @@ import after from './rules/after'; | ||
export { default as isUploaded } from './rules/isUploaded'; | ||
export { shorterThan } from './rules/shorterThan'; | ||
export { longerThan } from './rules/longerThan'; | ||
export declare type ArgFunc<T extends object, R> = (value: string, row: T) => R; | ||
@@ -21,0 +23,0 @@ export declare type MsgFunc<T extends object, A = any> = (value: string, row: T, arg?: A | ArgFunc<T, A>) => string; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.whitelist = exports.url = exports.required = exports.regex = exports.notEquals = exports.lessthan = exports.int = exports.greaterthan = exports.float = exports.equalto = exports.equals = exports.email = exports.domain = exports.blacklist = exports.before = exports.after = exports.longerThan = exports.shorterThan = exports.isUploaded = exports.atleastOneRequired = void 0; | ||
const lodash_get_1 = __importDefault(require("lodash.get")); | ||
@@ -42,5 +43,9 @@ const lodash_update_1 = __importDefault(require("lodash.update")); | ||
var atleastOneRequired_1 = require("./rules/atleastOneRequired"); | ||
exports.atleastOneRequired = atleastOneRequired_1.default; | ||
Object.defineProperty(exports, "atleastOneRequired", { enumerable: true, get: function () { return __importDefault(atleastOneRequired_1).default; } }); | ||
var isUploaded_1 = require("./rules/isUploaded"); | ||
exports.isUploaded = isUploaded_1.default; | ||
Object.defineProperty(exports, "isUploaded", { enumerable: true, get: function () { return __importDefault(isUploaded_1).default; } }); | ||
var shorterThan_1 = require("./rules/shorterThan"); | ||
Object.defineProperty(exports, "shorterThan", { enumerable: true, get: function () { return shorterThan_1.shorterThan; } }); | ||
var longerThan_1 = require("./rules/longerThan"); | ||
Object.defineProperty(exports, "longerThan", { enumerable: true, get: function () { return longerThan_1.longerThan; } }); | ||
; | ||
@@ -47,0 +52,0 @@ ; |
import { ValidationPromise } from '../'; | ||
declare const domain: (domains: string[]) => ValidationPromise<any, any>; | ||
declare const domain: (domains: string[]) => ValidationPromise<any>; | ||
export default domain; |
@@ -9,7 +9,7 @@ "use strict"; | ||
if (!Array.isArray(value)) { | ||
return reject(msg(String(value), row, Object.assign({}, arg, { type: 'INVALID_FORMAT' }))); | ||
return reject(msg(String(value), row, Object.assign(Object.assign({}, arg), { type: 'INVALID_FORMAT' }))); | ||
} | ||
value = value.map((v) => v.toLowerCase()); | ||
if (domains.some((d) => value.includes(d.toLowerCase()))) { | ||
return reject(msg(String(value), row, Object.assign({}, arg, { type: 'IN_USE' }))); | ||
return reject(msg(String(value), row, Object.assign(Object.assign({}, arg), { type: 'IN_USE' }))); | ||
} | ||
@@ -23,5 +23,5 @@ const regex = new RegExp('^(?!:\/\/)(?![a-zA-Z0-9-_]+@)([a-zA-Z0-9-_]+)(\.[a-zA-Z]{2,11}?)+$'); | ||
} | ||
reject(msg(String(value), row, Object.assign({}, arg, { type: 'INCORRECT' }))); | ||
reject(msg(String(value), row, Object.assign(Object.assign({}, arg), { type: 'INCORRECT' }))); | ||
}); | ||
}; | ||
exports.default = domain; |
{ | ||
"name": "validate-promise", | ||
"version": "3.5.3", | ||
"version": "3.6.0", | ||
"description": "Promised based validation library", | ||
@@ -19,11 +19,12 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/chai-as-promised": "^7.1.2", | ||
"@types/mocha": "^5.2.7", | ||
"@babel/register": "^7.10.5", | ||
"@types/chai-as-promised": "^7.1.3", | ||
"@types/mocha": "^8.0.3", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"jsdom": "^15.1.1", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.1.1", | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.5.3" | ||
"jsdom": "^16.4.0", | ||
"mocha": "^8.1.2", | ||
"nyc": "^15.1.0", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.2" | ||
}, | ||
@@ -30,0 +31,0 @@ "repository": { |
@@ -310,2 +310,24 @@ # validate-promise | ||
### Longer Than | ||
```javascript | ||
import { longerThan } from 'validate-promise'; | ||
contract = [ | ||
{ | ||
key: 'name', | ||
promises: [ | ||
{ | ||
rule: longerThan, | ||
arg: (value: any, row: Object) => ({min: 18, max: 55}) | ||
} | ||
], | ||
msg: (value, row, arg) => value + ' has fewer than 10 characters' | ||
}] | ||
``` | ||
Tests to ensure the length of the string you are validating is longer than the value supplied in | ||
the contract's arg. | ||
### Required | ||
@@ -327,2 +349,23 @@ | ||
### Shorter Than | ||
```javascript | ||
import {shorterThan} from 'validate-promise'; | ||
contract = [ | ||
{ | ||
key: 'name', | ||
promises: [ | ||
{ | ||
rule: shorterThan, | ||
arg: (value: any, row: Object) => ({min: 18, max: 55}) | ||
} | ||
], | ||
msg: (value, row, arg) => value + ' has more than 10 characters' | ||
}] | ||
``` | ||
Tests to ensure the length of the string you are validating is less than the value supplied in | ||
the contract's arg. | ||
### Url | ||
@@ -394,2 +437,2 @@ | ||
Expects the form's upload property to be a `Record<string, number>` type. Successfully validates if all | ||
of its values are 100. | ||
of its values are 100. |
@@ -23,2 +23,4 @@ import get from 'lodash.get'; | ||
export { default as isUploaded } from './rules/isUploaded'; | ||
export { shorterThan } from './rules/shorterThan'; | ||
export { longerThan } from './rules/longerThan'; | ||
@@ -79,3 +81,3 @@ /** | ||
/** | ||
* Iterates over an array of promises, unline Promise.all it will not | ||
* Iterates over an array of promises, unlike Promise.all it will not | ||
* stop when one promise is rejected. Instead all promises are run and an | ||
@@ -82,0 +84,0 @@ * array of objects describing the promise resolution is returned |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
127
3333
436
297108
10