Skip to content

Commit

Permalink
new test cases on boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
bitnbytesio committed Jul 20, 2019
1 parent e8c7b05 commit 28b756b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 28 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@types/mocha": "^5.2.7",
"@types/moment": "^2.13.0",
"@types/validator": "^10.11.1",
"coveralls": "^3.0.4",
"coveralls": "^3.0.5",
"eslint": "^5.16.0",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^5",
Expand Down
3 changes: 0 additions & 3 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ module.exports.applyRules = async function apply(field, validator) {

if (field.multiple) {


let fieldArr = field.path;

let fieldName = field.field;



for (let i in validator.inputs[fieldArr[0]]) {

let item = validator.inputs[fieldArr[0]][i];
Expand Down
28 changes: 27 additions & 1 deletion test/rules/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ describe('boolean', function () {

});

it('validation should pass: with false as boolean', async () => {

const v = new Validator(
{ attribute: false },
{ attribute: 'boolean' }
);

const matched = await v.check();

assert.equal(matched, true);

});

it('validation should pass: with 0 as integer', async () => {

const v = new Validator(
{ attribute: 0 },
{ attribute: 'boolean' }
);

const matched = await v.check();

assert.equal(matched, true);

});

it('validation should pass: with 0', async () => {

const v = new Validator(
Expand Down Expand Up @@ -76,5 +102,5 @@ describe('boolean', function () {

});


});

0 comments on commit 28b756b

Please sign in to comment.