Validator base class.
Validator is identified by a combination of own class name and all arguments. That is, validator is the same as other if one is instantiate from same class with same arguments.
Note
All arguments of validator are must be serializable.
Because identifier of validator was generated by pickle.
Validator’s identifier getter method (decoreted by property()).
It is string that generated from Validator’s all arguments.
Do validate.
Parameters: | value – Validatee value. |
---|
AND operation for validators.
OR operation for validators.
Adapt value to validators when validate a value.
Value processor.
Must be return processed value.
NOT operation for validator.
Raises ValidationError: | |
---|---|
Not raised ValidationError from the validator given at initialization. |
Surely fail validator.
Raises ValidationError: | |
---|---|
Always the exception raises. |
Surely pass validator.
Number validator.
Parameters: |
|
---|
Validate the value.
Parameters: | value (Accepted type of float().) – A number. |
---|---|
Raises: |
|
Free text validator.
Parameters: |
|
---|---|
Raises: |
|
Equal value validator.
Parameters: | eq_value – If the value is the same as eq_value is evaluated as “valid”. |
---|
Note
If type of value is str and type of eq_value is unicode, the value is treated as UTF-8 string.
Raises InvalidValueError: | |
---|---|
The value is not equal to eq_value or Failed decode eq_value to UTF-8. |
Value validation by regexp.
Parameters: |
|
---|---|
Raises InvalidValueError: | |
Regexp pattern is not found in the value. |
Constractor.
Raises TypeError: | |
---|---|
regexp is not string. |
Is TYPE allowed the value?
Parameters: |
|
---|---|
Raises: |
|
Constractor.
Raises ValueError: | |
---|---|
test_type is not callable. |
Prefix validator.
Parameters: | prefix – If value that starts from prefix, evaluate the value as “valid”. |
---|---|
Raises InvalidValueError: | |
The value is not prefixed. |
Type of the value validator.
Parameters: | value_type – Expected type of the value. |
---|---|
Raises InvalidTypeError: | |
Type of the value is not same as value_type. |
Limitation of length.
Parameters: |
|
---|---|
Raises InvalidValueError: | |
Value has exceeded the limit of the length. |
Split value validator.
usage:
>>> console = Any(Equal('001'), Equal('101'))
>>> model_number = Split(Equal('HVC'), console, sep='-')
>>> model_number('HVC-001')
>>> model_number('HVC-002')
validators.InvalidValueError: 002 is not equal to 001
Parameters: |
|
---|---|
Raises InvalidValueError: | |
The value can’t decode to unicode or number of splitted values and number of validators does not match. |
Free text without linefeed code.
Arguments are the same as FreeText.
Raises: |
|
---|
String type only.
Raises InvalidTypeError: | |
---|---|
The type of value is not string. |
Int type only.
Raises InvalidTypeError: | |
---|---|
The type of value is not int. |
Sort order validator.
Raises InvalidValueError: | |
---|---|
The value is not equal to asc or desc. |
Flag validator.
“true” and “t” and “1” as True.
“false” and “f” and “0” as False.
Note
The value ignore case.
Raises InvalidValueError: | |
---|---|
Not allowed value was given. |