Python 3.9 is now generally available.


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.