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
Truethen an error will be raised if avalidate()fails: Othwewisevalidate()will return a boolean value indicationg success or failure. DefaultTruetype_instance_check (bool, optional) – If
Truethenvalidate()args are tested also for isinstance if type does not match, rather then just type check if type is a match. IfFalsethen values willl only be tested as type. DefaultTrue
- validate(*args, **kwargs) bool[source]
Validates all
*argsand all**kwargsagainsttypesthat are passed into constructor.- Returns
Trueif all*argsand all**kwargmatch a type; Otherwise;False.- Return type
bool
- Raises
TypeError – if
raise_errorisTrueand validation fails.
- property raise_error: bool
Determines if errors will be raised during validation
If
Truethen 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
Truethenvalidate`()args are tested also for isinstance if type does not match, rather then just type check if type is a match. IfFalsethen 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