SubClassChecker Class
- class kwhelp.checks.SubClassChecker(*args: type, **kwargs)[source]
Class that validates args is a subclass of a give 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. DefaultTrueopt_inst_only (bool, optional) – If
Truethen validation will requires all values being tested to be an instance of a class. IfFalsevaladition will test class instance and class type. DefaultTrue
- validate(*args, **kwargs) bool[source]
Validates all
*argsand all**kwargsagainsttypesthat are passed into constructor.- Returns
Trueif all*argsand all**kwargmatch a valid class; Otherwise;False.- Return type
bool
- Raises
TypeError – if
raise_errorisTrueand validation fails.
- property instance_only: bool
Determines if validation requires instance of class
If
Truethen validation will fail when a type is validated, rather then an instance of a class.- Getter
Gets instance_only.
- Setter
Sets instance_only.
- 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 types: Tuple[type]
Gets the types passed into constructor that are used for validating args