View source on GitHub
|
Ensures that values in HttpHeadersDict are valid.
Inherits From: Validator, expected_type
google.appengine.api.appinfo.HttpHeadersDict.ValueValidator(
default=None
)
An instance is used as HttpHeadersDict's VALUE_VALIDATOR.
Args | |
|---|---|
default
|
Default assignment is made during initialization and will not pass through validation. |
Child Classes
Methods
AssertHeaderNotTooLong
@staticmethodAssertHeaderNotTooLong( name, value )
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
)
Convert value to a simplified collection or basic type.
Subclasses of Validator should override this method when the dumped
representation of value is not a simple <type>(value) (e.g., a regex).
| Args | |
|---|---|
value
|
An object of the same type that was returned from Validate().
|
| Returns | |
|---|---|
An instance of a builtin type (e.g., int, str, dict, etc). By default
it returns value unmodified.
|
Validate
Validate(
value, key=None
)
Returns a value, or raises an exception if the value is invalid.
According to RFC 2616 section 4.2_ header field values must consist "of
either *TEXT or combinations of token, separators, and quoted-string"::
TEXT = <any OCTET except CTLs, but including LWS>
| Args | |
|---|---|
value
|
HTTP header field value. |
key
|
HTTP header field name. |
| Returns | |
|---|---|
| A value argument. |
| Raises | |
|---|---|
appinfo_errors.InvalidHttpHeaderValue
|
An argument cannot be used as an HTTP header value. |
.. _RFC 2616, section 4.2: https://www.ietf.org/rfc/rfc2616.txt
__call__
__call__(
value, key='???'
)
Main interface to validator is call mechanism.
View source on GitHub