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

Commit 73007b1

Browse files
committed
fix(rules:equals): perform loose comparison
since rules can be string and their values can be a number a loose == comparison is required Closes #69
1 parent ac07f38 commit 73007b1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Validations/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ Validations.equals = function (data, field, message, args, get) {
982982
return
983983
}
984984

985-
if (targetedValue === fieldValue) {
985+
if (targetedValue == fieldValue) {
986986
resolve('validation passed')
987987
return
988988
}

test/validations.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,19 @@ describe('Validations', function() {
11601160
const passes = yield Validations.equals(data, field, message, args, get)
11611161
expect(passes).to.equal('validation passed')
11621162
})
1163+
1164+
///////////////////
1165+
// test suite 82 //
1166+
///////////////////
1167+
it('should work fine when then under validation is a number', function * () {
1168+
const data = {age:18}
1169+
const field = 'age'
1170+
const message = 'age should be 18'
1171+
const get = _.get
1172+
const args = ['18']
1173+
const passes = yield Validations.equals(data, field, message, args, get)
1174+
expect(passes).to.equal('validation passed')
1175+
})
11631176
})
11641177

11651178
context('notEquals', function () {

0 commit comments

Comments
 (0)