validate-promise
Advanced tools
Comparing version 3.6.0 to 3.6.1
@@ -1,1 +0,1 @@ | ||
{"processes":{"37c2060c-da1f-4c3b-9912-ab7023c875b8":{"parent":null,"children":[]},"c18a4a4f-c934-4c5c-a9d1-cba3ffe72f00":{"parent":null,"children":[]}},"files":{},"externalIds":{}} | ||
{"processes":{"06b9bbc6-e915-47c7-9727-20d2fe77365b":{"parent":null,"children":[]},"487aa6cb-dda9-40e1-9aef-09af061eb490":{"parent":null,"children":[]}},"files":{"/home/rob/validate-promise/src/index.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/after.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/before.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/blacklist.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/domain.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/email.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/equals.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/equalto.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/float.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/greaterthan.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/int.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/lessthan.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/notEquals.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/regex.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/required.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/url.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/whitelist.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/atleastOneRequired.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/isUploaded.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/shorterThan.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"],"/home/rob/validate-promise/src/rules/longerThan.ts":["06b9bbc6-e915-47c7-9727-20d2fe77365b","487aa6cb-dda9-40e1-9aef-09af061eb490"]},"externalIds":{}} |
@@ -5,8 +5,8 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
if (value !== '' && value !== undefined) { | ||
if ((typeof value === 'string' && value.trim() !== '') && value !== undefined) { | ||
return resolve(); | ||
} | ||
return reject(msg(value, row)); | ||
return reject(msg(String(value), row)); | ||
}); | ||
}; | ||
exports.default = required; |
{ | ||
"name": "validate-promise", | ||
"version": "3.6.0", | ||
"version": "3.6.1", | ||
"description": "Promised based validation library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,6 +8,6 @@ import { ValidationPromise } from '../'; | ||
return new Promise((resolve, reject) => { | ||
if (value !== '' && value !== undefined) { | ||
if ((typeof value === 'string' && value.trim() !== '') && value !== undefined) { | ||
return resolve(); | ||
} | ||
return reject(msg(value, row)); | ||
return reject(msg(String(value), row)); | ||
}); | ||
@@ -14,0 +14,0 @@ }; |
@@ -166,2 +166,26 @@ import { expect } from 'chai'; | ||
describe('String containing spaces', () => { | ||
it('fails if only spaces', async () => { | ||
try { | ||
await validate(contract, { name: ' ' }); | ||
expect.fail(0, 1, 'Validation should not pass'); | ||
} catch (e) { | ||
expect(e).to.deep.equal({ | ||
name: ['Name is required'], | ||
}); | ||
} | ||
}); | ||
it('passes if starting & ending with spaces but contains other characters', async () => { | ||
try { | ||
const res = await validate(contract, { name: ' Rob ' }); | ||
expect(res).to.equal(true); | ||
} catch (e) { | ||
expect.fail(0, 1, 'Validation should not fail'); | ||
} | ||
}); | ||
}) | ||
describe('required failed', () => { | ||
@@ -221,3 +245,3 @@ beforeEach((done) => { | ||
}); | ||
}) | ||
}); | ||
@@ -224,0 +248,0 @@ describe('Runs a validation and fails as the condition is still applicable', () => { |
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
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
514078
3353