Watson - Validators¶
Validate and verify arbitrary values.
Build Status¶
Installation¶
pip install watson-validators
Testing¶
Watson can be tested with py.test. Simply activate your virtualenv and run python setup.py test
.
Contributing¶
If you would like to contribute to Watson, please feel free to issue a pull request via Github with the associated tests for your code. Your name will be added to the AUTHORS file under contributors.
Table of Contents¶
Reference Library¶
watson.validators.numeric¶
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.
-