TypeChecker Class
- class kwhelp.checks.TypeChecker(*args: type, **kwargs)[source]
Class that validates args match a given type
- __init__(*args: type, **kwargs)[source]
Constructor
- Other Arguments:
args (type): One or more types used for Validation purposes.
- Keyword Arguments
raise_error (bool, optional) – If
True
then an error will be raised if avalidate()
fails: Othwewisevalidate()
will return a boolean value indicationg success or failure. DefaultTrue
type_instance_check (bool, optional) – If
True
thenvalidate()
args are tested also for isinstance if type does not match, rather then just type check if type is a match. IfFalse
then values willl only be tested as type. DefaultTrue
- validate(*args, **kwargs) bool [source]
Validates all
*args
and all**kwargs
againsttypes
that are passed into constructor.- Returns
True
if all*args
and all**kwarg
match a type; Otherwise;False
.- Return type
bool
- Raises
TypeError – if
raise_error
isTrue
and validation fails.
- property raise_error: bool
Determines if errors will be raised during validation
If
True
then errors will be raised when validation fails.- Getter
Gets if errors can be raised.
- Setter
Sets if errors can be raised.
- property type_instance_check: bool
Determines if instance checking is done with type checking.
If
True
thenvalidate`()
args are tested also for isinstance if type does not match, rather then just type check if type is a match. IfFalse
then values willl only be tested as type.- Getter
Gets type_instance_check value
- Setter
Sets type_instance_check value
- property types: Tuple[type]
Gets the types passed into constructor that are used for validating args