RuleNotNone Class

class kwhelp.rules.RuleNotNone(key: str, name: str, value: object, raise_errors: bool, originator: object)[source]

Bases: kwhelp.rules.IRule

Rule that matched only if value is not None.

__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 to attribute is not None.

Raises

ValueError – If raise_errors is True and field_value is None.

Returns

True if field_value is not None; 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