validate-promise
Advanced tools
Comparing version 3.2.2 to 3.2.3
@@ -1,1 +0,1 @@ | ||
{"processes":{"66fec98f-95a0-4113-844a-d835efba706e":{"parent":null,"children":["e4fadf61-84c3-4277-bff1-53ffa1eda86d"]},"7df7854f-4e8e-4cfe-bdbf-04ee72091f35":{"parent":null,"children":[]},"e4fadf61-84c3-4277-bff1-53ffa1eda86d":{"parent":"66fec98f-95a0-4113-844a-d835efba706e","children":[]}},"files":{"/home/rob/validate-promise/src/index.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/after.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/atleastOneRequired.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/before.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/blacklist.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/email.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/equals.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/equalto.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/float.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/greaterthan.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/int.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/isUploaded.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/lessthan.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/notEquals.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/regex.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/required.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"],"/home/rob/validate-promise/src/rules/whitelist.ts":["7df7854f-4e8e-4cfe-bdbf-04ee72091f35","e4fadf61-84c3-4277-bff1-53ffa1eda86d"]},"externalIds":{}} | ||
{"processes":{"21645775-2538-4b07-8506-8b0c8bb466c0":{"parent":null,"children":[]},"6b90070c-fa2f-4b50-9b4a-96b0069ff620":{"parent":"e916e402-23e9-4725-886b-c9daf4d34e26","children":[]},"e916e402-23e9-4725-886b-c9daf4d34e26":{"parent":null,"children":["6b90070c-fa2f-4b50-9b4a-96b0069ff620"]}},"files":{"/home/rob/validate-promise/src/index.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/after.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/atleastOneRequired.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/before.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/blacklist.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/email.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/equals.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/equalto.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/float.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/greaterthan.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/int.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/isUploaded.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/lessthan.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/notEquals.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/regex.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/required.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"],"/home/rob/validate-promise/src/rules/whitelist.ts":["21645775-2538-4b07-8506-8b0c8bb466c0","6b90070c-fa2f-4b50-9b4a-96b0069ff620"]},"externalIds":{}} |
import { ValidationPromise } from '../'; | ||
declare const after: ValidationPromise; | ||
declare const after: ValidationPromise<any>; | ||
export default after; |
import { ValidationPromise } from '../'; | ||
declare const atleastOneRequried: ValidationPromise; | ||
declare const atleastOneRequried: ValidationPromise<any>; | ||
export default atleastOneRequried; |
import { ValidationPromise } from '../'; | ||
declare const before: ValidationPromise; | ||
declare const before: ValidationPromise<any>; | ||
export default before; |
import { ValidationPromise } from '../'; | ||
declare const blacklist: ValidationPromise; | ||
declare const blacklist: ValidationPromise<any>; | ||
export default blacklist; |
import { ValidationPromise } from '../'; | ||
declare const email: ValidationPromise; | ||
declare const email: ValidationPromise<any>; | ||
export default email; |
import { ValidationPromise } from '../'; | ||
declare const equals: ValidationPromise; | ||
declare const equals: ValidationPromise<any>; | ||
export default equals; |
import { ValidationPromise } from '../'; | ||
declare const equalsTo: ValidationPromise; | ||
declare const equalsTo: ValidationPromise<any>; | ||
export default equalsTo; |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
}; | ||
declare const float: ValidationPromise<object, FloatBoundsType>; | ||
declare const float: ValidationPromise<any, FloatBoundsType>; | ||
export default float; |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
}; | ||
declare const greaterthan: ValidationPromise<object, CompareSet>; | ||
declare const greaterthan: ValidationPromise<any, CompareSet>; | ||
export default greaterthan; |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
}; | ||
declare const int: ValidationPromise<object, IntBoundsType>; | ||
declare const int: ValidationPromise<any, IntBoundsType>; | ||
export default int; |
import { ValidationPromise } from '../'; | ||
declare const isUpladed: ValidationPromise<object, number | Record<string, number>>; | ||
declare const isUpladed: ValidationPromise<any, number | Record<string, number>>; | ||
export default isUpladed; |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
}; | ||
declare const lessthan: ValidationPromise<object, CompareSet>; | ||
declare const lessthan: ValidationPromise<any, CompareSet>; | ||
export default lessthan; |
import { ValidationPromise } from '../'; | ||
declare const notEquals: ValidationPromise; | ||
declare const notEquals: ValidationPromise<any>; | ||
export default notEquals; |
import { ValidationPromise } from '../'; | ||
declare const regex: ValidationPromise; | ||
declare const regex: ValidationPromise<any>; | ||
export default regex; |
import { ValidationPromise } from '../'; | ||
declare const required: ValidationPromise; | ||
declare const required: ValidationPromise<any>; | ||
export default required; |
import { ValidationPromise } from '../'; | ||
declare const whitelist: ValidationPromise; | ||
declare const whitelist: ValidationPromise<any>; | ||
export default whitelist; |
{ | ||
"name": "validate-promise", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "Promised based validation library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const after: ValidationPromise = ( | ||
const after: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const atleastOneRequried: ValidationPromise = ( | ||
const atleastOneRequried: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const before: ValidationPromise = ( | ||
const before: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const blacklist: ValidationPromise = ( | ||
const blacklist: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -8,3 +8,3 @@ import isEmail from 'is-email'; | ||
*/ | ||
const email: ValidationPromise = ( | ||
const email: ValidationPromise<any> = ( | ||
value, | ||
@@ -11,0 +11,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const equals: ValidationPromise = ( | ||
const equals: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const equalsTo: ValidationPromise = ( | ||
const equalsTo: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -11,3 +11,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const float: ValidationPromise<object, FloatBoundsType> = ( | ||
const float: ValidationPromise<any, FloatBoundsType> = ( | ||
value, | ||
@@ -14,0 +14,0 @@ row, |
@@ -11,3 +11,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const greaterthan: ValidationPromise<object, CompareSet> = ( | ||
const greaterthan: ValidationPromise<any, CompareSet> = ( | ||
value, | ||
@@ -14,0 +14,0 @@ row, |
@@ -11,3 +11,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const int: ValidationPromise<object, IntBoundsType> = ( | ||
const int: ValidationPromise<any, IntBoundsType> = ( | ||
value, | ||
@@ -14,0 +14,0 @@ row, |
import { ValidationPromise } from '../'; | ||
const isUpladed: ValidationPromise<object, number | Record<string, number>> = ( | ||
const isUpladed: ValidationPromise<any, number | Record<string, number>> = ( | ||
value, | ||
@@ -8,3 +8,3 @@ row, | ||
arg, | ||
): Promise<any> => { | ||
) => { | ||
if (value === undefined) { | ||
@@ -11,0 +11,0 @@ return Promise.reject(msg(value, row, arg)); |
@@ -11,3 +11,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const lessthan: ValidationPromise<object, CompareSet> = ( | ||
const lessthan: ValidationPromise<any, CompareSet> = ( | ||
value, | ||
@@ -14,0 +14,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const notEquals: ValidationPromise = ( | ||
const notEquals: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
@@ -11,3 +11,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const regex: ValidationPromise = ( | ||
const regex: ValidationPromise<any> = ( | ||
value, | ||
@@ -14,0 +14,0 @@ row, |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const required: ValidationPromise = (value, row, msg) => { | ||
const required: ValidationPromise<any> = (value, row, msg) => { | ||
return new Promise((resolve, reject) => { | ||
@@ -9,0 +9,0 @@ if (value !== '' && value !== undefined) { |
@@ -6,3 +6,3 @@ import { ValidationPromise } from '../'; | ||
*/ | ||
const whitelist: ValidationPromise = ( | ||
const whitelist: ValidationPromise<any> = ( | ||
value, | ||
@@ -9,0 +9,0 @@ row, |
import { expect } from 'chai'; | ||
import validate, { lessthan } from '../src/index'; | ||
import validate, { | ||
lessthan, | ||
Validation, | ||
} from '../src/index'; | ||
interface IDataCleanerRow { | ||
test: '1,', | ||
} | ||
const typedContract: Validation<IDataCleanerRow>[] = [ | ||
{ | ||
key: 'name', | ||
promises: [ | ||
{ | ||
rule: lessthan, | ||
}, | ||
], | ||
msg: () => 'Name is required' | ||
} | ||
]; | ||
describe('validates', () => { | ||
let res, failed, resLessThanSuccess, | ||
contract = [ | ||
{key: 'age', | ||
{ | ||
key: 'age', | ||
promises: [ | ||
@@ -18,4 +38,4 @@ { | ||
contractReturnObject = [ | ||
{ | ||
contractReturnObject = [ | ||
{ | ||
key: 'age', | ||
@@ -25,3 +45,3 @@ promises: [ | ||
rule: lessthan, | ||
arg: () => ({compare: 21, value: 19}) | ||
arg: () => ({ compare: 21, value: 19 }) | ||
} | ||
@@ -51,2 +71,21 @@ ], | ||
describe('typed contract: less than success', () => { | ||
beforeEach(done => { | ||
let data = { | ||
age: '17' | ||
}; | ||
validate(typedContract, data) | ||
.then(data => { | ||
res = data; | ||
done(); | ||
}) | ||
.catch(error => done()); | ||
}); | ||
it('passes the validation', () => { | ||
expect(res).to.equal(true); | ||
}); | ||
}); | ||
describe('less than success: return object', () => { | ||
@@ -53,0 +92,0 @@ beforeEach(done => { |
import { expect } from 'chai'; | ||
import validate, { required } from '../src/index'; | ||
import validate, { | ||
required, | ||
Validation, | ||
} from '../src/index'; | ||
interface IDataCleanerRow { | ||
active: boolean; | ||
column: string | number; | ||
id: string; | ||
func: string; | ||
cutset?: string; | ||
prefix?: string; | ||
old?: string; | ||
new?: string; | ||
start?: string; | ||
end?: string; | ||
} | ||
const typedContract: Validation<IDataCleanerRow>[] = [ | ||
{ | ||
key: 'name', | ||
promises: [ | ||
{ | ||
rule: required, | ||
}, | ||
], | ||
msg: () => 'Name is required' | ||
} | ||
]; | ||
describe('validates', () => { | ||
let res, failed, | ||
contract = [ | ||
contract: Validation[] = [ | ||
{ | ||
@@ -30,3 +59,3 @@ key: 'name', | ||
], | ||
contractThree = [ | ||
contractThree: Validation[] = [ | ||
{ | ||
@@ -44,3 +73,3 @@ key: 'name', | ||
beforeEach((done) => { | ||
let contract = [ | ||
let contract: Validation[] = [ | ||
{ | ||
@@ -70,2 +99,23 @@ key: 'name', | ||
describe('required on typed validation contract', () => { | ||
beforeEach((done) => { | ||
let data = { | ||
name: 'heloo' | ||
}; | ||
res = false; | ||
validate(typedContract, data) | ||
.then((data) => { | ||
res = data; | ||
done(); | ||
}) | ||
.catch((error) => { | ||
failed = error; | ||
done(); | ||
}); | ||
}); | ||
it('passes validation', () => { | ||
expect(res).to.equal(true); | ||
}) | ||
}) | ||
describe('required - one fail and one success', () => { | ||
@@ -72,0 +122,0 @@ beforeEach((done) => { |
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
350132
2765