You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've bumped to the odd behavior of the in rule. It throws ok when it should have not to.
My validating object must have status field. The status value must be in the array of possible values [1, 2, 3, 4].
So validation rule is defined like that: status: 'required|in:1,2,3,4'.
When status is 0 validator says everything is fine but mustn't as there is no 0 int the giving possible values.
I also tried to rewrite rule. Somehow like that status: [ 'required', { in: [1, 2, 3, 4] }] and got the same wrong result.
Then I cloned validatorjs and added test case to the spec/in-rule.js file.
it("should fail when 0 (zero) is not in giving arra",function(){constvalidator=newValidator({quantity: 0},{quantity: "in:1,2"});expect(validator.passes()).to.be.false;expect(validator.fails()).to.be.true;});
So my test case doesn't pass. Am I doing something wrong? Or this is bug?
The text was updated successfully, but these errors were encountered:
I've bumped to the odd behavior of the
in
rule. It throwsok
when it should have not to.My validating object must have
status
field. Thestatus
value must be in the array of possible values[1, 2, 3, 4]
.So validation rule is defined like that:
status: 'required|in:1,2,3,4'
.When
status
is0
validator says everything is fine but mustn't as there is no0
int the giving possible values.I also tried to rewrite rule. Somehow like that
status: [ 'required', { in: [1, 2, 3, 4] }]
and got the same wrong result.Then I cloned
validatorjs
and added test case to thespec/in-rule.js
file.So my test case doesn't pass. Am I doing something wrong? Or this is bug?
The text was updated successfully, but these errors were encountered: