View source on GitHub |
Base class for all validated objects.
Inherits From: expected_type
Methods
CheckInitialized
CheckInitialized()
Checks for missing or conflicting attributes.
Subclasses should override this function and raise an exception for any errors. Always run this method when all assignments are complete.
Raises | |
---|---|
ValidationError
|
When there are missing or conflicting attributes. |
GetValidator
@classmethod
GetValidator( key )
Safely get the Validator corresponding to the given key.
This function should be overridden by subclasses
Args | |
---|---|
key
|
The attribute or item to get a validator for. |
Returns | |
---|---|
Validator associated with key or attribute. |
Raises | |
---|---|
ValidationError
|
If the requested key is illegal. |
GetWarnings
GetWarnings()
Return all the warnings we've got, along with their associated fields.
Returns | |
---|---|
A list of tuples of (dotted_field, warning), both strings. |
Set
Set(
key, value
)
Set a single value on Validated instance.
This method should be overridded by sub-classes.
This method can only be used to assign validated attributes/items.
Args | |
---|---|
key
|
The name of the attributes |
value
|
The value to set |
Raises | |
---|---|
ValidationError
|
When no validated attribute exists on class. |
SetMultiple
SetMultiple(
attributes
)
Set multiple values on Validated instance.
All attributes will be validated before being set.
Args | |
---|---|
attributes
|
A dict of attributes/items to set. |
Raises | |
---|---|
ValidationError
|
When no validated attribute exists on class. |
ToDict
ToDict()
Convert ValidatedBase
object to a dictionary.
Recursively traverses all of its elements and converts everything to simplified collections.
Subclasses should override this method.
Returns | |
---|---|
A dictionary mapping all attributes to simple values or collections. |
ToYAML
ToYAML()
Print validated object as simplified YAML.
Returns | |
---|---|
Object as a simplified YAML string compatible with parsing using the
SafeLoader .
|