App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Public Attributes | List of all members
google.appengine.api.validation.Regex Class Reference
Inheritance diagram for google.appengine.api.validation.Regex:
google.appengine.api.validation.Validator

Public Member Functions

def __init__
 
def Validate
 
- Public Member Functions inherited from google.appengine.api.validation.Validator
def __init__
 
def __call__
 
def Validate
 
def ToValue
 

Public Attributes

 re
 
 expected_type
 
- Public Attributes inherited from google.appengine.api.validation.Validator
 default
 

Additional Inherited Members

- Static Public Attributes inherited from google.appengine.api.validation.Validator
 expected_type = object
 

Detailed Description

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)

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

The documentation for this class was generated from the following file: