Skip to content

Commit 31bc68c

Browse files
committed
Replaced the API window.debug to window.Debug to unify the debug process.
1 parent 4db4065 commit 31bc68c

File tree

3 files changed

+92
-26
lines changed

3 files changed

+92
-26
lines changed

html5-form-validation.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"validation",
1010
"input"
1111
],
12-
"version": "1.3.0",
12+
"version": "1.3.1",
1313
"author": {
1414
"name": "Tom Bertrand",
1515
"url": "http://www.runningcoder.org/jqueryvalidation/"

jquery.validation.js

Lines changed: 89 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* jQuery Form Validation
33
*
44
* @author Tom Bertrand
5-
* @version 1.3.0 (2014-07-25)
5+
* @version 1.3.1 (2014-07-31)
66
*
77
* @copyright
88
* Copyright (C) 2014 Tom Bertrand.
@@ -1328,22 +1328,43 @@
13281328
if (typeof node === "function") {
13291329

13301330
if (!options.submit.settings.form) {
1331-
window.debug('$.validate - Undefined property "options.submit.settings.form" - Validation dropped.');
1331+
1332+
window.Debug.log({
1333+
'node': node,
1334+
'function': '$.validate()',
1335+
'arguments': '',
1336+
'message': 'Undefined property "options.submit.settings.form - Validation dropped'
1337+
});
1338+
1339+
window.Debug.print();
13321340
return;
13331341
}
13341342

13351343
node = $(options.submit.settings.form);
13361344

13371345
if (!node[0]) {
1338-
window.debug('$.validate - Unable to find jQuery form element "options.submit.settings.form" - ' + options.submit.settings.form + ' - Validation dropped.');
1346+
window.Debug.log({
1347+
'node': node,
1348+
'function': '$.validate()',
1349+
'arguments': JSON.stringify(options.submit.settings.form),
1350+
'message': 'Unable to find jQuery form element - Validation dropped'
1351+
});
1352+
1353+
window.Debug.print();
13391354
return;
13401355
}
13411356

13421357
} else if (typeof node[0] === 'undefined') {
13431358

1344-
window.debug('$("' + node['selector'] + '").validate() - Unable to find jQuery element - Validation dropped.');
1345-
return;
1359+
window.Debug.log({
1360+
'node': node,
1361+
'function': '$.validate()',
1362+
'arguments': '$("' + node['selector'] + '").validate()',
1363+
'message': 'Unable to find jQuery form element - Validation dropped'
1364+
});
13461365

1366+
window.Debug.print();
1367+
return;
13471368
}
13481369

13491370
return node.each(function () {
@@ -1469,12 +1490,28 @@
14691490
addError: function (node, error) {
14701491

14711492
if (!window.Validation.form[node.selector]) {
1472-
window.debug('$.addError - Invalid node selector - Make sure you are using the same one you initialize the Validation with.');
1493+
1494+
window.Debug.log({
1495+
'node': node,
1496+
'function': '$.addError()',
1497+
'arguments': 'window.Validation.form[' + JSON.stringify(node.selector) + ']',
1498+
'message': 'ERROR - Invalid node selector'
1499+
});
1500+
1501+
window.Debug.print();
14731502
return false;
14741503
}
14751504

14761505
if (typeof error !== "object" || Object.prototype.toString.call(error) !== "[object Object]") {
1477-
window.debug('$.addError - Invalid error object.');
1506+
1507+
window.Debug.log({
1508+
'node': node,
1509+
'function': '$.addError()',
1510+
'arguments': 'window.Validation.form[' + JSON.stringify(node.selector) + ']',
1511+
'message': 'ERROR - Invalid argument, must be type object'
1512+
});
1513+
1514+
window.Debug.print();
14781515
return false;
14791516
}
14801517

@@ -1492,7 +1529,15 @@
14921529

14931530
input = $(node.selector).find('[name="'+ inputName + '"]');
14941531
if (!input[0]) {
1495-
window.debug('$.addError - Unable to find [name="' + inputName + '"] inside form: ' + node.selector + '.');
1532+
1533+
window.Debug.log({
1534+
'node': node,
1535+
'function': '$.addError()',
1536+
'arguments': JSON.stringify(inputName),
1537+
'message': 'ERROR - Unable to find ' + '$(' + node.selector + ').find("[name="'+ inputName + '"]")'
1538+
});
1539+
1540+
window.Debug.print();
14961541
continue;
14971542
}
14981543

@@ -1506,7 +1551,15 @@
15061551
for (var i = 0; i < error[inputName].length; i++) {
15071552

15081553
if (typeof error[inputName][i] !== "string") {
1509-
window.debug('$.addError - Invalid error object property - Accepted format: {"inputName": "errorString"} or {"inputName": ["errorString", "errorString"]}.');
1554+
1555+
window.Debug.log({
1556+
'node': node,
1557+
'function': '$.addError()',
1558+
'arguments': JSON.stringify(error[inputName][i]),
1559+
'message': 'ERROR - Invalid error object property - Accepted format: {"inputName": "errorString"} or {"inputName": ["errorString", "errorString"]}'
1560+
});
1561+
1562+
window.Debug.print();
15101563
continue;
15111564
}
15121565

@@ -1538,7 +1591,15 @@
15381591
removeError: function (node, inputName) {
15391592

15401593
if (!window.Validation.form[node.selector]) {
1541-
window.debug('$.removeError - Invalid node selector - Make sure you are using the same one you initialize the Validation with.');
1594+
1595+
window.Debug.log({
1596+
'node': node,
1597+
'function': '$.removeError()',
1598+
'arguments': 'window.Validation.form[' + JSON.stringify(node.selector) + ']',
1599+
'message': 'ERROR - Invalid node selector'
1600+
});
1601+
1602+
window.Debug.print();
15421603
return false;
15431604
}
15441605

@@ -1548,7 +1609,15 @@
15481609
}
15491610

15501611
if (typeof inputName === "object" && Object.prototype.toString.call(inputName) !== "[object Array]") {
1551-
window.debug('$.removeError - Invalid inputName array.');
1612+
1613+
window.Debug.log({
1614+
'node': node,
1615+
'function': '$.removeError()',
1616+
'arguments': JSON.stringify(inputName),
1617+
'message': 'ERROR - Invalid inputName, must be type String or Array'
1618+
});
1619+
1620+
window.Debug.print();
15521621
return false;
15531622
}
15541623

@@ -1561,7 +1630,15 @@
15611630

15621631
input = $(node.selector).find('[name="'+ inputName[i] + '"]');
15631632
if (!input[0]) {
1564-
window.debug('$.removeError - Unable to find [name="' + inputName[i] + '"] inside form: ' + node.selector + '.');
1633+
1634+
window.Debug.log({
1635+
'node': node,
1636+
'function': '$.removeError()',
1637+
'arguments': JSON.stringify(inputName[i]),
1638+
'message': 'ERROR - Unable to find ' + '$(' + node.selector + ').find("[name="'+ inputName[i] + '"]")'
1639+
});
1640+
1641+
window.Debug.print();
15651642
continue;
15661643
}
15671644

@@ -1573,17 +1650,6 @@
15731650

15741651
};
15751652

1576-
/**
1577-
* Creates a fail-safe debugging system inside the console
1578-
*/
1579-
window.debug = function () {
1580-
if (this.console && this.console.debug) {
1581-
this.console.debug('DEBUG: ' + Array.prototype.slice.call(arguments));
1582-
} else {
1583-
window.log('DEBUG: ' + Array.prototype.slice.call(arguments));
1584-
}
1585-
};
1586-
15871653
window.Debug = {
15881654

15891655
table: {},

0 commit comments

Comments
 (0)