watson.validators.string¶
-
class
watson.validators.string.
Csrf
(token=None, message='Cross-Site request forgery attempt detected, invalid token specified "{token}"')[source]¶ Validates a csrf token.
Example:
validator = Csrf() validator('submitted token')
-
class
watson.validators.string.
Length
(min=-1, max=-1, message='"{value}" does not meet the required length')[source]¶ Validates the length of a string.
Example:
validator = Length(1, 10) validator('Test') # True validator('Testing maximum') # raises ValueError
-
__init__
(min=-1, max=-1, message='"{value}" does not meet the required length')[source]¶ Initializes the validator.
Min, max, length are interpolated into the message.
Parameters: - min (int) – The minimum length of the string.
- max (int) – The maximum length of the string.
- message (string) – The message to be used if the validator fails.
-