1616# limitations under the License.
1717
1818class Chef
19- class ValidationFailed < ArgumentError
20- end
2119
2220module Mixin
2321module ParamsValidate
@@ -112,7 +110,7 @@ def _pv_required(opts, key, is_required=true)
112110( opts . has_key? ( key . to_sym ) && !opts [ key . to_sym ] . nil? )
113111true
114112else
115- raise ValidationFailed , "Required argument #{ key } is missing!"
113+ raise Exceptions :: ValidationFailed , "Required argument #{ key } is missing!"
116114end
117115end
118116end
@@ -125,7 +123,7 @@ def _pv_equal_to(opts, key, to_be)
125123passes = true if value == tb
126124end
127125unless passes
128- raise ValidationFailed , "Option #{ key } must be equal to one of: #{ to_be . join ( ", " ) } ! You passed #{ value . inspect } ."
126+ raise Exceptions :: ValidationFailed , "Option #{ key } must be equal to one of: #{ to_be . join ( ", " ) } ! You passed #{ value . inspect } ."
129127end
130128end
131129end
@@ -139,7 +137,7 @@ def _pv_kind_of(opts, key, to_be)
139137passes = true if value . kind_of? ( tb )
140138end
141139unless passes
142- raise ValidationFailed , "Option #{ key } must be a kind of #{ to_be } ! You passed #{ value . inspect } ."
140+ raise Exceptions :: ValidationFailed , "Option #{ key } must be a kind of #{ to_be } ! You passed #{ value . inspect } ."
143141end
144142end
145143end
@@ -150,14 +148,14 @@ def _pv_respond_to(opts, key, method_name_list)
150148unless value . nil?
151149Array ( method_name_list ) . each do |method_name |
152150unless value . respond_to? ( method_name )
153- raise ValidationFailed , "Option #{ key } must have a #{ method_name } method!"
151+ raise Exceptions :: ValidationFailed , "Option #{ key } must have a #{ method_name } method!"
154152end
155153end
156154end
157155end
158156
159157# Assert that parameter returns false when passed a predicate method.
160- # For example, :cannot_be => :blank will raise a ValidationFailed
158+ # For example, :cannot_be => :blank will raise a Exceptions:: ValidationFailed
161159# error value.blank? returns a 'truthy' (not nil or false) value.
162160#
163161# Note, this will *PASS* if the object doesn't respond to the method.
@@ -169,7 +167,7 @@ def _pv_cannot_be(opts, key, predicate_method_base_name)
169167
170168if value . respond_to? ( predicate_method )
171169if value . send ( predicate_method )
172- raise ValidationFailed , "Option #{ key } cannot be #{ predicate_method_base_name } "
170+ raise Exceptions :: ValidationFailed , "Option #{ key } cannot be #{ predicate_method_base_name } "
173171end
174172end
175173end
@@ -195,7 +193,7 @@ def _pv_regex(opts, key, regex)
195193end
196194end
197195unless passes
198- raise ValidationFailed , "Option #{ key } 's value #{ value } does not match regular expression #{ regex . to_s } "
196+ raise Exceptions :: ValidationFailed , "Option #{ key } 's value #{ value } does not match regular expression #{ regex . to_s } "
199197end
200198end
201199end
@@ -207,7 +205,7 @@ def _pv_callbacks(opts, key, callbacks)
207205if value != nil
208206callbacks . each do |message , zeproc |
209207if zeproc . call ( value ) != true
210- raise ValidationFailed , "Option #{ key } 's value #{ value } #{ message } !"
208+ raise Exceptions :: ValidationFailed , "Option #{ key } 's value #{ value } #{ message } !"
211209end
212210end
213211end
0 commit comments