toolchest.validator¶
- class toolchest.validator.base.BaseValidator[source]¶
Bases:
object- static validate(validator, item_to_validate)[source]¶
A method to allow calling of any validator, with checking to only return True or an error, so that the validator cannot inject code into the caller.
- Parameters
validator (func) – A function to use to validate the format of an item. This function should throw a ValueError if the pattern does not match.
item_to_validate (obj) – A value to validate
- Returns
Returns True if pattern matches
- Raises
ValueError – If the item cannot be validated with the validator, a ValueError is thrown.