Skip to content

Commit

Permalink
fix(formvalidation): check if field is undefined before accessing
Browse files Browse the repository at this point in the history
Check if `validation[field] !== undefined` before accessing any of it's properties
  • Loading branch information
iarspider authored and Sean committed Mar 12, 2019
1 parent 9c3ee37 commit f7c21e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,12 @@ $.fn.form = function(parameters) {
? rule
: [rule]
;
if(rule == undefined) {
module.debug('Removed all rules');
validation[field].rules = [];
if(validation[field] === undefined || !Array.isArray(validation[field].rules)) {
return;
}
if(validation[field] == undefined || !Array.isArray(validation[field].rules)) {
if(rule === undefined) {
module.debug('Removed all rules');
validation[field].rules = [];
return;
}
$.each(validation[field].rules, function(index, rule) {
Expand Down

0 comments on commit f7c21e9

Please sign in to comment.