@@ -141,14 +141,13 @@ def result(evaluation_result) -> Tuple[Dict, bool]:
141
141
class ExactMatchType (CheckType ):
142
142
"""Exact Match class docstring."""
143
143
144
- @staticmethod
145
- def _validate (** kwargs ) -> None :
146
- """Method to validate arguments."""
147
- # reference_data = getattr(kwargs, "reference_data")
144
+ def _validate (referece_data ):
145
+ # No need for _validate method as exact-match does not take any specific arguments.
146
+ pass
148
147
149
148
def evaluate (self , value_to_compare : Any , reference_data : Any ) -> Tuple [Dict , bool ]:
150
149
"""Returns the difference between values and the boolean."""
151
- self . _validate ( reference_data = reference_data )
150
+
152
151
evaluation_result = diff_generator (reference_data , value_to_compare )
153
152
return self .result (evaluation_result )
154
153
@@ -157,10 +156,9 @@ class ToleranceType(CheckType):
157
156
"""Tolerance class docstring."""
158
157
159
158
@staticmethod
160
- def _validate (** kwargs ) -> None :
159
+ def _validate (tolerance ) -> None :
161
160
"""Method to validate arguments."""
162
161
# reference_data = getattr(kwargs, "reference_data")
163
- tolerance = kwargs .get ("tolerance" )
164
162
if not tolerance :
165
163
raise ValueError ("'tolerance' argument is mandatory for Tolerance Check Type." )
166
164
if not isinstance (tolerance , (int , float )):
@@ -170,7 +168,7 @@ def _validate(**kwargs) -> None:
170
168
171
169
def evaluate (self , value_to_compare : Any , reference_data : Any , tolerance : int ) -> Tuple [Dict , bool ]:
172
170
"""Returns the difference between values and the boolean. Overwrites method in base class."""
173
- self ._validate (reference_data = reference_data , tolerance = tolerance )
171
+ self ._validate (tolerance = tolerance )
174
172
evaluation_result = diff_generator (reference_data , value_to_compare )
175
173
self ._remove_within_tolerance (evaluation_result , tolerance )
176
174
return self .result (evaluation_result )
@@ -206,16 +204,14 @@ class ParameterMatchType(CheckType):
206
204
"""Parameter Match class implementation."""
207
205
208
206
@staticmethod
209
- def _validate (** kwargs ) -> None :
207
+ def _validate (params , mode ) -> None :
210
208
"""Method to validate arguments."""
211
209
mode_options = ["match" , "no-match" ]
212
- params = kwargs .get ("params" )
213
210
if not params :
214
211
raise ValueError ("'params' argument is mandatory for ParameterMatch Check Type." )
215
212
if not isinstance (params , dict ):
216
213
raise ValueError (f"'params' argument must be a dict. You have: { type (params )} ." )
217
214
218
- mode = kwargs .get ("mode" )
219
215
if not mode :
220
216
raise ValueError ("'mode' argument is mandatory for ParameterMatch Check Type." )
221
217
if mode not in mode_options :
@@ -235,16 +231,14 @@ class RegexType(CheckType):
235
231
"""Regex Match class implementation."""
236
232
237
233
@staticmethod
238
- def _validate (** kwargs ) -> None :
234
+ def _validate (regex , mode ) -> None :
239
235
"""Method to validate arguments."""
240
236
mode_options = ["match" , "no-match" ]
241
- regex = kwargs .get ("regex" )
242
237
if not regex :
243
238
raise ValueError ("'regex' argument is mandatory for Regex Check Type." )
244
239
if not isinstance (regex , str ):
245
240
raise ValueError (f"'regex' argument must be a string. You have: { type (regex )} ." )
246
241
247
- mode = kwargs .get ("mode" )
248
242
if not mode :
249
243
raise ValueError ("'mode' argument is mandatory for Regex Check Type." )
250
244
if mode not in mode_options :
@@ -261,7 +255,7 @@ class OperatorType(CheckType):
261
255
"""Operator class implementation."""
262
256
263
257
@staticmethod
264
- def _validate (** kwargs ) -> None :
258
+ def _validate (params ) -> None :
265
259
"""Validate operator parameters."""
266
260
in_operators = ("is-in" , "not-in" , "in-range" , "not-range" )
267
261
bool_operators = ("all-same" ,)
@@ -275,15 +269,16 @@ def _validate(**kwargs) -> None:
275
269
)
276
270
277
271
# Validate "params" argument is not None.
278
- if not kwargs or list (kwargs .keys ())[0 ] != "params" :
279
- raise ValueError (f"'params' argument must be provided. You have: { list (kwargs .keys ())[0 ]} ." )
272
+ # {'params': {'mode': 'all-same', 'operator_data': True}}
273
+ if not params or list (params .keys ())[0 ] != "params" :
274
+ raise ValueError (f"'params' argument must be provided. You have: { list (params .keys ())[0 ]} ." )
280
275
281
- params_key = kwargs [ " params" ] .get ("mode" )
282
- params_value = kwargs [ " params" ] .get ("operator_data" )
276
+ params_key = params .get ("mode" )
277
+ params_value = params .get ("operator_data" )
283
278
284
279
if not params_key or not params_value :
285
280
raise ValueError (
286
- f"'mode' and 'operator_data' arguments must be provided. You have: { list (kwargs ['params' ].keys ())} ."
281
+ f"'mode' and 'operator_data' arguments must be provided. You have: { list (params ['params' ].keys ())} ."
287
282
)
288
283
289
284
# Validate "params" value is legal.
@@ -334,7 +329,7 @@ def _validate(**kwargs) -> None:
334
329
335
330
def evaluate (self , value_to_compare : Any , params : Any ) -> Tuple [Dict , bool ]:
336
331
"""Operator evaluator implementation."""
337
- self ._validate (** params )
332
+ self ._validate (params )
338
333
# For name consistency.
339
334
reference_data = params
340
335
evaluation_result = operator_evaluator (reference_data ["params" ], value_to_compare )
0 commit comments