class_inspector.custom_validators module¶
- class_inspector.custom_validators.validate_bool_func(bool_func) Callable ¶
Validate the value using a custom boolean function.
- Parameters:
bool_func – The boolean function to apply to the value.
- Returns:
A validation function.
- Return type:
Callable
- Raises:
TypeError – If the provided boolean function is not callable.
- class_inspector.custom_validators.validate_collection(instance, attribute, value) None ¶
Validate that the value is a subclass of Collection.
- Parameters:
instance – The instance the attribute belongs to.
attribute – The attribute being validated.
value – The value of the attribute.
- Raises:
TypeError – If the value is not a subclass of Collection.
- class_inspector.custom_validators.validate_collection_of_type(allowed_type: Type) Callable ¶
Validate that the value is a collection of a specific type.
- Parameters:
allowed_type (Type) – The type each item in the collection should be.
- Returns:
A validation function.
- Return type:
Callable
- Raises:
TypeError – If the value is not a subclass of Collection.
- class_inspector.custom_validators.validate_generic(generic_type: Type) Callable ¶
Validate that the value is a subclass of a specific generic type.
- Parameters:
generic_type (Type) – The generic type.
- Returns:
A validation function.
- Return type:
Callable
- class_inspector.custom_validators.validate_generic_bool_func(generic_type: Type, bool_func: Callable) Callable ¶
Validate that the value is a collection of a specific generic type using a custom boolean function.
- Parameters:
generic_type (Type) – The generic type.
bool_func (Callable) – The boolean function to apply to each item.
- Returns:
A validation function.
- Return type:
Callable
- Raises:
TypeError – If the provided boolean function is not callable.
- class_inspector.custom_validators.validate_generic_of_type(generic_type: Type, allowed_type: Type) Callable ¶
Validate that the value is a collection of a specific generic type.
- Parameters:
generic_type (Type) – The generic type.
allowed_type (Type) – The type each item in the collection should be.
- Returns:
A validation function.
- Return type:
Callable
- class_inspector.custom_validators.validate_iterable(instance, attribute, value) None ¶
Validate that the value is a subclass of Iterable.
- Parameters:
instance – The instance the attribute belongs to.
attribute – The attribute being validated.
value – The value of the attribute.
- Raises:
TypeError – If the value is not a subclass of Iterable.
- class_inspector.custom_validators.validate_iterable_of_type(allowed_type: Type) Callable ¶
Validate that the value is an iterable of a specific type.
- Parameters:
allowed_type (Type) – The type each item in the iterable should be.
- Returns:
A validation function.
- Return type:
Callable
- Raises:
TypeError – If the value is not a subclass of Iterable.
- class_inspector.custom_validators.validate_sequence(instance, attribute, value) None ¶
Validate that the value is a subclass of Sequence.
- Parameters:
instance – The instance the attribute belongs to.
attribute – The attribute being validated.
value – The value of the attribute.
- Raises:
TypeError – If the value is not a subclass of Sequence.
- class_inspector.custom_validators.validate_sequence_of_type(allowed_type: Type) Callable ¶
Validate that the value is a sequence of a specific type.
- Parameters:
allowed_type (Type) – The type each item in the sequence should be.
- Returns:
A validation function.
- Return type:
Callable
- Raises:
TypeError – If the value is not a subclass of Sequence.