argclz.validator.StrValidatorBuilder#
- class argclz.validator.StrValidatorBuilder[source]#
Bases:
AbstractTypeValidatorBuilder[str]a str validator
Methods Summary
__init__()contains(*texts)Check if string values contain a substring
ends_with(suffix)Check if string values end with a substring
freeze(*args, **kwargs)(internal use) return a copy of itself.
length_in_range(a, b, /)Enforce a string length range
match(r)Check if string matches a regular expression
one_of(options)Check if string is one of the allow options
optional()starts_with(prefix)Check if string values start with a substring
__call__(value)Details
- starts_with(prefix)[source]#
Check if string values start with a substring
- Parameters:
prefix (str)
- Return type:
- ends_with(suffix)[source]#
Check if string values end with a substring
- Parameters:
suffix (str)
- Return type:
- contains(*texts)[source]#
Check if string values contain a substring
- Parameters:
texts (str)
- Return type:
- one_of(options)[source]#
Check if string is one of the allow options
- Parameters:
options (Collection[str])
- Return type:
- __call__(value)#
- Parameters:
value (Any) – type-casted value.
- Returns:
True if value pass the validation.
- Raises:
ValueError – when value does not pass the validation.
- Return type:
- freeze(*args, **kwargs)#
(internal use) return a copy of itself.
- Return type:
Self
- optional()#
- Return type:
Self