RuleIterable Class
- class kwhelp.rules.RuleIterable(key: str, name: str, value: object, raise_errors: bool, originator: object)[source]
Bases:
kwhelp.rules.IRule
Rule that matched only if value is iterable such as list, tuple, set.
- __init__(key: str, name: str, value: object, raise_errors: bool, originator: object)
Constructor
- Parameters
key (str) – the key that rule is to apply to.
name (str) – the name of the field that value was assigned
value (object) – the value that is assigned to
field_name
raise_errors (bool) – determinins if rule could raise an error when validation fails
originator (object) – the object that attributes validated for
- Raises
TypeError – If any arg is not of the correct type
- validate() bool [source]
Validates that value to assign is iterable
- Raises
TypeError – If
raise_errors
isTrue
andfield_value
is not iterable.- Returns
True
iffield_value
is a iterable; Otherwise,False
.- Return type
bool
- property field_name: str
Name of the field assigned.
- Getter
Gets the name of the field assigned
- Setter
Sets the name of the field assigned
- property field_value: object
The value assigned to
field_name
- Getter
Gets value assigned to
field_name
- Setter
Sets value assigned to
field_name
- property key: str
Gets the key currently being read
- property originator: object
Gets object that attributes validated for
- property raise_errors: bool
Determines if a rule can raise an error when validation fails.
- Getter
Gets if a rule could raise an error when validation fails
- Setter
Sets if a rule could raise an error when validation fails