Skip to content

Commit

Permalink
Fixes #36136 - make sure validatorRule is a string (#601)
Browse files Browse the repository at this point in the history
* Fixes #36136 - make sure validatorRule is a string

variable.validatorRule.split was raising a TypeError:
string.split is not a function

(cherry picked from commit bba4f31)

* Updated REX and foreman-tasks dependencies

---------

Co-authored-by: Ron Lavi <1ronlavi@gmail.com>
  • Loading branch information
nofaralfasi and Ron-Lavi committed Feb 23, 2023
1 parent ec45749 commit 07e4d65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions foreman_ansible.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Gem::Specification.new do |s|

s.add_dependency 'acts_as_list', '~> 1.0.3'
s.add_dependency 'deface', '< 2.0'
s.add_dependency 'foreman_remote_execution', '>= 4.4.0'
s.add_dependency 'foreman-tasks', '>= 5.2.0'
s.add_dependency 'foreman_remote_execution', '~> 7.2.2'
s.add_dependency 'foreman-tasks', '~> 6.0.3'
end
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ const validateRegexp = (variable, value) => {
};

const validateList = (variable, value) => {
if (variable.validatorRule.split(',').find(item => item.trim() === value)) {
let { validatorRule } = variable;
if (typeof validatorRule !== 'string') {
validatorRule = validatorRule.toString();
}
if (validatorRule.split(',').find(item => item.trim() === value)) {
return validationSuccess;
}
return {
key: 'error',
msg: sprintf(__('Invalid, expected one of: %s'), variable.validatorRule),
msg: sprintf(__('Invalid, expected one of: %s'), validatorRule),
};
};

Expand Down

0 comments on commit 07e4d65

Please sign in to comment.