Skip to content

Commit c2c9b92

Browse files
committed
added unit tests for data validation
1 parent f8c5927 commit c2c9b92

File tree

8 files changed

+46
-17
lines changed

8 files changed

+46
-17
lines changed

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 1.9.30
15+
* @version 1.9.32
1616
*/
1717
(function($) {
1818

form-validator/jquery.form-validator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Documentation and issue tracking on Github <https://github.com/victorjonsson/jQuery-Form-Validator/>
66
*
77
* @license Dual licensed under the MIT or GPL Version 2 licenses
8-
* @version 1.9.30
8+
* @version 1.9.32
99
*/
1010
(function($) {
1111

@@ -1301,8 +1301,8 @@
13011301
name : 'validate_date',
13021302
validate : function(date, $el, conf) {
13031303
var dateFormat = 'yyyy-mm-dd';
1304-
if($el.attr('data-format')) {
1305-
dateFormat = $el.attr('data-format');
1304+
if($el.attr('data-validation-format')) {
1305+
dateFormat = $el.attr('data-validation-format');
13061306
}
13071307
else if(typeof conf.dateFormat != 'undefined') {
13081308
dateFormat = conf.dateFormat;

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* @license Dual licensed under the MIT or GPL Version 2 licenses
14-
* @version 1.9.30
14+
* @version 1.9.32
1515
*/
1616
(function($) {
1717

form-validator/security.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* - validate_backend
1313
*
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 1.9.30
15+
* @version 1.9.32
1616
*/
1717
(function($) {
1818

form-validator/sweden.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* - validate_swephone
1414
*
1515
* @license Dual licensed under the MIT or GPL Version 2 licenses
16-
* @version 1.9.30
16+
* @version 1.9.32
1717
*/
1818
(function($) {
1919

form-validator/test.html

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,25 +232,54 @@
232232
/*
233233
* LENGTH VALIDATION
234234
*/
235+
test("Date validation", function() {
236+
237+
clearForm();
238+
239+
var dates = [
240+
{val:'2000-01-01', isValid:true},
241+
{val:'2000-01-1', isValid:false},
242+
{val:'2000-01-32', isValid:false},
243+
{val:'2000-02-29', isValid:true}, // leap year
244+
{val:'2013-02-29', isValid:false},
245+
{val:'2000-04-31', isValid:false},
246+
{val:'2000-13-1', isValid:false},
247+
{val:'2000-1-1', isValid:false},
248+
{val:'-01-01', isValid:false},
249+
{val:input('01/01/2000', {'format':'dd/mm/yyyy', '':'date'}), isValid:true},
250+
{val:input('29/02/2000', {'format':'dd/mm/yyyy', '':'date'}), isValid:true},
251+
{val:input('29/02/2013', {'format':'dd/mm/yyyy', '':'date'}), isValid:false},
252+
{val:input('29/13/2013', {'format':'dd/mm/yyyy', '':'date'}), isValid:false},
253+
{val:input('29/00/2013', {'format':'dd/mm/yyyy', '':'date'}), isValid:false}
254+
];
255+
256+
$.each(dates, function(i, obj) {
257+
runTest(obj, 'date');
258+
});
259+
});
260+
261+
/*
262+
* DATE VALIDATION
263+
*/
235264
test("Length validation", function() {
236265

237266
clearForm();
238267

239268
var links = [
240-
{val:input('1234', {'length':'max3', '':'length'}, {name:6}), isValid:false},
241-
{val:input('1234', {'length':'min3', '':'length'}, {name:5}), isValid:true},
242-
{val:input('1234', {'length':'min5', '':'length'}, {name:4}), isValid:false},
243-
{val:input('1234', {'length':'2-35', '':'length'}, {name:3}), isValid:true},
244-
{val:input('123456', {'length':'2-5', '':'length'}, {name:3}), isValid:false},
245-
{val:input('1234', {'length':'max4', '':'length'}, {name:1}), isValid:true},
269+
{val:input('1234', {'length':'max3', '':'length'}), isValid:false},
270+
{val:input('1234', {'length':'min3', '':'length'}), isValid:true},
271+
{val:input('1234', {'length':'min5', '':'length'}), isValid:false},
272+
{val:input('1234', {'length':'2-35', '':'length'}), isValid:true},
273+
{val:input('123456', {'length':'2-5', '':'length'}), isValid:false},
274+
{val:input('1234', {'length':'max4', '':'length'}), isValid:true},
246275
{val:input('1234', {length : 'min5', '':'number length'}), isValid:false},
247276
{val:input('12345', {length : 'min5', '':'number length'}), isValid:true},
248277
{val:input('1234a', {length : 'min5', '':'number length'}), isValid:false},
249278
{val:input('12345678', {length : 'min5', '':'number length'}), isValid:true}
250279
];
251280

252281
$.each(links, function(i, obj) {
253-
runTest(obj, 'domain');
282+
runTest(obj, 'length');
254283
});
255284
});
256285

form-validator/uk.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* - validate_ukvatnumber
1010
*
1111
* @license Dual licensed under the MIT or GPL Version 2 licenses
12-
* @version 1.9.30
12+
* @version 1.9.32
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'validate_ukvatnumber',

0 commit comments

Comments
 (0)