View source on GitHub |
Validates that a string can compile as a regex without errors.
Inherits From: Validator
, expected_type
google.appengine.api.validation.RegexStr(
string_type=six.text_type, default=None
)
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.
Args | |
---|---|
string_type
|
Type to be considered a string. |
default
|
Default value. |
Raises | |
---|---|
AttributeDefinitionError
|
If string_type is not a kind of string.
|
Child Classes
Methods
CheckFieldInitialized
CheckFieldInitialized(
value, key, obj
)
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
GetWarnings(
value, key, obj
)
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
|
ToValue
ToValue(
value
)
Returns the RE
pattern for this validator.
Validate
Validate(
value, key
)
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__
__call__(
value, key='???'
)
Main interface to validator is call mechanism.