String Rules
Length
Validator to check if the length of a string value falls within a specified range.
Parameters:
- min_length (int): The minimum allowed length of the string.
- max_length (int): The maximum allowed length of the string.
- message (str): The error message to be used if the validation fails.
MinLength
Validator to check if a value has a minimum length.
Parameters:
- min (int): The minimum length that the value must have.
- message (str): The error message to be used if the validation fails.
MaxLength
Validator to check if a value has a maximum length.
Parameters:
- max (int): The maximum length that the value must have.
- message (str): The error message to be used if the validation fails.
NotBlank
Validator to check if a string value is not blank (empty or contains only whitespace).
Parameters:
- message (str): The error message to be used if the validation fails.
InList
Validator to check if a string value is present in a specified list.
Parameters:
- valid_values (list): The list of valid values.
- message (str): The error message to be used if the validation fails.
Example
NotInList
Validator to check if a string value is not present in a specified list.
Parameters:
- invalid_values (list): The list of invalid values.
- message (str): The error message to be used if the validation fails.
Example
DoesntStartsWith
Validate that a string value does not start with any of the specified prefixes.
Parameters:
- list_prefix (list of str): The list of prefixes that the string should not start with.
- message (str): The error message template if validation fails.
Example
StartsWith
Validate that a string value does not start with any of the specified prefixes.
Parameters:
- list_prefix (list of str): The list of prefixes that the string should not start with.
- message (str): The error message template if validation fails.
Example
DoesntEndsWith
Validate that a string value does not start with any of the specified prefixes.
Parameters:
- list_prefix (list of str): The list of prefixes that the string should not start with.
- message (str): The error message template if validation fails.
Example
EndsWith
Validate that a string value ends with one of the specified suffixes.
Parameters:
- list_tail (list of str): The list of suffixes that the string should end with.
- message (str): The error message template if validation fails.
Example
Equals
Validate that a string value is equal to another specified value.
Parameters:
- another_value (str): The value to compare against.
- message (str): The error message template if validation fails.
Example
NotEquals
Validate that a string value is not equal to another specified value.
Parameters:
- another_value: The value to compare against.
- message (str): The error message template if validation fails.