![]() |
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 | |
re | |
expected_type | |
![]() | |
default | |
Additional Inherited Members | |
![]() | |
expected_type = object | |
Regular expression validator. Regular expression validator always converts value to string. Note that matches must be exact. Partial matches will not validate. For example: class ClassDescr(Validated): ATTRIBUTES = { 'name': Regex(r'[a-zA-Z_][a-zA-Z_0-9]*'), 'parent': Type(type), } Alternatively, any attribute that is defined as a string is automatically interpreted to be of type Regex. It is possible to specify unicode regex strings as well. This approach is slightly less efficient, but usually is not significant unless parsing large amounts of data: class ClassDescr(Validated): ATTRIBUTES = { 'name': r'[a-zA-Z_][a-zA-Z_0-9]*', 'parent': Type(type), } # This will raise a ValidationError exception. my_class(name='AName with space', parent=AnotherClass)
def google.appengine.api.validation.Regex.__init__ | ( | self, | |
regex, | |||
string_type = unicode , |
|||
default = None |
|||
) |
Initialized regex validator. Args: regex: Regular expression string to use for comparison. Raises: AttributeDefinitionError: if string_type is not a kind of string.
def google.appengine.api.validation.Regex.Validate | ( | self, | |
value, | |||
key | |||
) |
Does validation of a string against a regular expression. Args: value: String to match against regular expression. key: Name of the field being validated. Raises: ValidationError: when value does not match regular expression or when value does not match provided string type.