google.appengine.api.validation.RegexStr

Validates that a string can compile as a regex without errors.

Inherits From: Validator, expected_type

Use this validator when the value of a field should be a regex. That means that the value must be a string that can be compiled by re.compile(). The attribute will then be a compiled re object.

string_type Type to be considered a string.
default Default value.

AttributeDefinitionError If string_type is not a kind of string.

Child Classes

class expected_type

Methods

CheckFieldInitialized

View source

Check for missing fields or conflicts between fields.

Default behavior performs a simple None-check, but this can be overridden. If the intent is to allow optional fields, then use the Optional validator instead.

Args
value Value to validate.
key Name of the field being validated.
obj The object to validate against.

Raises
ValidationError When there are missing or conflicting fields.

GetWarnings

View source

Return any warnings on this attribute.

Validates the value with an eye towards things that aren't fatal problems.

Args
value Value to validate.
key Name of the field being validated.
obj The object to validate against.

Returns
A list of tuples (context, warning) where

  • Context is the field (or dotted field path, if a sub-field)
  • Warning is the string warning text

ToValue

View source

Returns the RE pattern for this validator.

Validate

View source

Validates that the string compiles as a regular expression.

Because the regular expression might have been expressed as a multiline string, this function also strips newlines out of value.

Args
value String to compile as a regular expression.
key Name of the field being validated.

Raises
ValueError when value does not compile as a regular expression. TypeError when value does not match provided string type.

__call__

View source

Main interface to validator is call mechanism.