class documentation

class ValidationRule:

View In Hierarchy

A validation rule for a property, e.g. ValidationRule(VALIDATION_RULE_TYPE.MAX_LENGTH, 200).

The rule is checked when it is constructed, so an invalid one never reaches a schema. Which rules a property may have depends on its datatype: an ENUM rule on an enum property, and REGEX, MIN_LENGTH and MAX_LENGTH rules on a text or keyword property.

Raises
ValueErrorIf rule_type is not a VALIDATION_RULE_TYPE, or a length is negative or a pattern is empty.
TypeErrorIf rule has the wrong type for rule_type.
Method __post_init__ Undocumented
Method to_dict The rule as it appears in a property's validationRules.
Instance Variable rule The rule's value: a non-negative integer for MIN_LENGTH and MAX_LENGTH, a non-empty pattern string for REGEX, or a sequence of allowed values for ENUM (stored as a tuple).
Instance Variable rule_type The kind of rule. A plain string such as 'maxLength' is converted to the matching VALIDATION_RULE_TYPE.
def __post_init__(self):

Undocumented

def to_dict(self) -> dict:

The rule as it appears in a property's validationRules.

rule: Any =

The rule's value: a non-negative integer for MIN_LENGTH and MAX_LENGTH, a non-empty pattern string for REGEX, or a sequence of allowed values for ENUM (stored as a tuple).

The kind of rule. A plain string such as 'maxLength' is converted to the matching VALIDATION_RULE_TYPE.