Python 3.9 is now generally available.

Module: google.appengine.api.validation

Validation tools for generic object structures.

This library is used for defining classes with constrained attributes. Attributes are defined on the class which contains them using validators. Although validators can be defined by any client of this library, a number of standard validators are provided here.

Validators can be any callable that takes a single parameter which checks the new value before it is assigned to the attribute. Validators are permitted to modify a received value so that it is appropriate for the attribute definition. For example, using int as a validator will cast a correctly formatted string to a number, or raise an exception if it can not. This is not recommended, however. The correct way to use a validator that ensures the correct type is to use the Type validator.

This validation library is mainly intended for use with the YAML object builder. See the yaml_object module.


class AttributeDefinitionError: An error occurred in the definition of class attributes.

class Deprecated: A deprecated field.

class Error: Base class for all package errors.

class Exec: Coerces the value to accommodate Docker CMD/ENTRYPOINT requirements.

class ItemDumper: For dumping validation.Items. Respects SortedDict key ordering.

class MissingAttribute: Raised when a required attribute is missing from object.

class Normalized: Normalizes a field on lookup, but serializes with the original value.

class Optional: Definition of optional attributes.

class Options: Limit field based on pre-determined values.

class Preferred: A non-deprecated field when there's a deprecated one.

class Range: Validates that numbers fall within the correct range.

class Regex: Regular expression validator.

class RegexStr: Validates that a string can compile as a regex without errors.

class Repeated: Repeated field validator.

class SortedDict: Represents a dict with a particular key order for yaml representing.

class StringValidator: Verifies property is a valid text string.

class TimeValue: Validates time values with units, such as 1h or 3.5d.

class Type: Verifies property is of expected type.

class Validated: Base class for classes that require validation.

class ValidatedBase: Base class for all validated objects.

class ValidatedDict: Base class for validated dictionaries.

class ValidationError: Base class for raising exceptions during validation.

class Validator: Validator base class.


AsValidator(...): Wrap various types as instances of a validator.

TYPE_BOOL(...): Verifies property is of expected type.

TYPE_FLOAT(...): Verifies property is of expected type.

TYPE_INT(...): Verifies property is of expected type.

TYPE_LONG(...): Verifies property is of expected type.

TYPE_STR(...): Verifies property is of expected type.

TYPE_UNICODE(...): Verifies property is of expected type.