Python 3.9 is now generally available.

google.appengine.api.validation.ValidatedBase

Base class for all validated objects.

Inherits From: expected_type

Methods

CheckInitialized

View source

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

View source

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

View source

Return all the warnings we've got, along with their associated fields.

Returns
A list of tuples of (dotted_field, warning), both strings.

Set

View source

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

View source

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

View source

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

View source

Print validated object as simplified YAML.

Returns
Object as a simplified YAML string compatible with parsing using the SafeLoader.