bootstack.validation.ValidationRule#
- class bootstack.validation.ValidationRule(rule_type, message='', **kwargs)#
Bases:
objectA single validation rule that can be applied to a string value.
Supports the built-in rule types
'required','email','stringLength','pattern','compare', and'custom', and carries a trigger policy that controls when the rule is evaluated.- trigger#
When the rule fires —
'always','key','blur', or'manual'.- Type:
RuleTriggerType
- params#
Additional parameters specific to the rule type (e.g.,
min/maxfor'stringLength',patternfor'pattern',other_fieldfor'compare',funcfor'custom').- Type:
- validate(value)#
Apply this rule to a value and return the result.
- Parameters:
value (str) – The string value to validate.
- Returns:
A ValidationResult with
is_valid=Trueon success oris_valid=Falsewith an error message on failure.A
'custom'rule whosefuncraises is reported invalid rather than allowed to propagate. Its message is “Could not check this value (expected: …)”, carrying the rule’s ownmessageas an expectation rather than as a verdict; a rule with nomessagereportsUNCHECKABLE_MESSAGE.- Return type: