Permalink
Browse files

Core: Allow 0 as value for autoCreateRanges

Closes #1293
  • Loading branch information...
jzaefferer committed Oct 14, 2014
1 parent 4cecd73 commit fe14d00a1d42c7195acecab27ee3d929a551419a
Showing with 8 additions and 8 deletions.
  1. +2 −2 src/core.js
  2. +6 −6 test/rules.js
View
@@ -1057,12 +1057,12 @@ $.extend( $.validator, {
if ( $.validator.autoCreateRanges ) {
// auto-create ranges
- if ( rules.min && rules.max ) {
+ if ( rules.min != null && rules.max != null ) {
rules.range = [ rules.min, rules.max ];
delete rules.min;
delete rules.max;
}
- if ( rules.minlength && rules.maxlength ) {
+ if ( rules.minlength != null && rules.maxlength != null ) {
rules.rangelength = [ rules.minlength, rules.maxlength ];
delete rules.minlength;
delete rules.maxlength;
View
@@ -84,19 +84,19 @@ test("rules(), merge min/max to range, minlength/maxlength to rangelength", func
$("#testForm1clean").validate({
rules: {
firstnamec: {
- min: 5,
- max: 12
+ min: -15,
+ max: 0
},
lastname: {
- minlength: 2,
- maxlength: 8
+ minlength: 0,
+ maxlength: 10
}
}
});
- deepEqual( $("#firstnamec").rules(), { range: [ 5, 12 ] } );
+ deepEqual( $("#firstnamec").rules(), { range: [ -15, 0 ] } );
+ deepEqual( $("#lastnamec").rules(), { rangelength: [ 0, 10 ] } );
- deepEqual( $("#lastnamec").rules(), { rangelength: [ 2, 8 ] } );
jQuery.validator.autoCreateRanges = false;
});

0 comments on commit fe14d00

Please sign in to comment.