Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
fix(rules:equals): perform loose comparison
Browse files Browse the repository at this point in the history
since rules can be string and their values can be a number a loose == comparison is required

Closes #69
  • Loading branch information
thetutlage committed Sep 23, 2016
1 parent ac07f38 commit 73007b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Validations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ Validations.equals = function (data, field, message, args, get) {
return
}

if (targetedValue === fieldValue) {
if (targetedValue == fieldValue) {
resolve('validation passed')
return
}
Expand Down
13 changes: 13 additions & 0 deletions test/validations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,19 @@ describe('Validations', function() {
const passes = yield Validations.equals(data, field, message, args, get)
expect(passes).to.equal('validation passed')
})

///////////////////
// test suite 82 //
///////////////////
it('should work fine when then under validation is a number', function * () {
const data = {age:18}
const field = 'age'
const message = 'age should be 18'
const get = _.get
const args = ['18']
const passes = yield Validations.equals(data, field, message, args, get)
expect(passes).to.equal('validation passed')
})
})

context('notEquals', function () {
Expand Down

0 comments on commit 73007b1

Please # to comment.