Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 3.10 is now available in preview.


Raises an exception if the value is not a valid string or a subclass thereof.

A string is valid if it's not empty, no more than _MAX_STRING_LENGTH bytes, and not a Blob. The exception type can be specified with the exception argument; it defaults to BadValueError.

value The value to validate.
name The name of this value; used in the exception message.
exception The type of exception to raise.
max_len The maximum allowed length, in bytes.
empty_ok Allow empty value.