Attribute
Attribute(reference: str, rule: Optional[AbstractRule] = None, mandatory: bool = True)
Validates an object attribute, even private ones.
You can also validate the attribute itself:
Third parameter makes the attribute presence optional (default True):
v.attribute('lorem', v.stringType(), False).validate(obj) # true
v.attribute('alexey', v.stringType(), mandatory=False).validate(obj) # true
v.attribute('alexey', v.stringType(), mandatory=True).validate(obj) # false
The name of this validator is automatically set to the attribute name.
Categorization
- Nesting
- Objects
- Structures
Changelog
Version | Description |
---|---|
1.0.0 | Created |
See also: