![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | Validate |
![]() | |
def | __init__ |
def | __call__ |
def | Validate |
def | ToValue |
Public Attributes | |
expected_type | |
convert | |
![]() | |
default | |
Additional Inherited Members | |
![]() | |
expected_type = object | |
Verifies property is of expected type. Can optionally convert value if it is not of the expected type. It is possible to specify a required field of a specific type in shorthand by merely providing the type. This method is slightly less efficient than providing an explicit type but is not significant unless parsing a large amount of information: class Person(Validated): ATTRIBUTES = {'name': unicode, 'age': int, } However, in most instances it is best to use the type constants: class Person(Validated): ATTRIBUTES = {'name': TypeUnicode, 'age': TypeInt, }
def google.appengine.api.validation.Type.__init__ | ( | self, | |
expected_type, | |||
convert = True , |
|||
default = None |
|||
) |
Initialize Type validator. Args: expected_type: Type that attribute should validate against. convert: Cause conversion if value is not the right type. Conversion is done by calling the constructor of the type with the value as its first parameter. default: Default assignment is made during initialization and will not pass through validation.
def google.appengine.api.validation.Type.Validate | ( | self, | |
value, | |||
key | |||
) |
Validate that value has the correct type. Args: value: Value to validate. key: Name of the field being validated. Returns: value if value is of the correct type. value is coverted to the correct type if the Validator is configured to do so. Raises: MissingAttribute: if value is None and the expected type is not NoneType. ValidationError: if value is not of the right type and the validator is either configured not to convert or cannot convert.