Technical Reference
handlers.base.cls
BaseHandler
Bases: ABC, Generic[V, A]
Abstract base class for all handlers in the pipeline.
Handlers are the building blocks of the pipeline, responsible for processing values (validation, matching, transformation) based on provided arguments and context. They support different modes of operation to handle single values, items in a collection, or values dependent on other context fields.
Attributes:
| Name | Type | Description |
|---|---|---|
FLAGS |
ClassVar[tuple[Flag, ...]]
|
Flags acting as settings for the handler.
Example: |
SUPPORT |
ClassVar[tuple[HandlerMode, ...]]
|
Supported handler modes.
- |
CONTEXT_ARGUMENT_BUILDER |
ClassVar[Callable | None]
|
Helper to build arguments from context. Used in CONTEXT mode to transform the context value before using it as an argument. |
Source code in pipeline/handlers/base/cls.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
__init__(value, argument, context=None, metadata=None, _mode=HandlerMode.ROOT, _item_use_key=False, _preferred_value_type=None)
Initializes the BaseHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
V
|
The value to process. |
required |
argument
|
A
|
The argument for the handler. |
required |
context
|
PipeContext | None
|
Additional context for the handler. |
None
|
metadata
|
PipeMetadata | None
|
Metadata about the pipe execution. |
None
|
_mode
|
HandlerMode
|
The mode in which the handler is operating. |
ROOT
|
_item_use_key
|
bool | None
|
If True and in ITEM mode, the handler operates on the key of a dictionary item instead of the value. |
False
|
_preferred_value_type
|
type | None
|
Specific type to prefer/enforce during type validation. |
None
|
Source code in pipeline/handlers/base/cls.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init_subclass__()
Extracts expected runtime types from class generics and sets a unique handler ID.
During subclass creation, this method:
1. Extracts generic type arguments for value and argument from class definition,
recursively unpacking them into tuples stored in cls._raw_expected_type for runtime type validation.
2. Generates a snake_case identifier (cls.id) from the class name.
Source code in pipeline/handlers/base/cls.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
handle()
Executes the handler logic based on the current mode.
It delegates to _handle() for ROOT and CONTEXT modes, and _handle_item_mode()
for ITEM mode.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The result of the handling operation. The return type depends on the specific |
Any
|
handler implementation (e.g., specific error type, boolean, or transformed value). |
Raises:
| Type | Description |
|---|---|
HandlerException
|
If the handler mode is invalid. |
Source code in pipeline/handlers/base/cls.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
handlers.base.modifiers
Context(handler)
Modifier ensure the handler is run in CONTEXT mode.
In CONTEXT mode, the handler's argument is retrieved from the pipeline context using the provided argument as a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Type[T]
|
The handler class to modify. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
partial |
A partial application of the handler with _mode=HandlerMode.CONTEXT. |
Source code in pipeline/handlers/base/modifiers.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Item(handler, use_key=False, only_consider=None)
Modifier to ensure the handler is run in ITEM mode.
In ITEM mode, the handler is applied to each item in an iterable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
Type[T] | partial[T]
|
The handler class or partial to modify. |
required |
use_key
|
bool | None
|
If True, the handler uses the item's key (e.g., in a dictionary) instead of value. |
False
|
only_consider
|
type | None
|
Specific type to filter items for processing. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
partial |
A partial application of the handler with ITEM mode settings. |
Source code in pipeline/handlers/base/modifiers.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
handlers.condition.cls
ConditionHandler
Bases: BaseHandler[V, A]
Abstract base class for specific condition implementations.
This class provides the infrastructure for condition checking, including error message generation
and support for different handling modes (ROOT, ITEM).
It expects subclasses to implement the query method.
Source code in pipeline/handlers/condition/cls.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
error_msg
property
Generates the error message based on the current mode and error templates.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The generated error message. |
Raises:
| Type | Description |
|---|---|
ConditionMissingRootErrorMsg
|
If the root error template is missing. |
__init__(value, argument, context=None, metadata=None, _mode=HandlerMode.ROOT, _item_use_key=False, _preferred_value_type=None)
Initializes the ConditionHandler.
It ensures that if ROOT mode is supported, a corresponding error template is present.
Source code in pipeline/handlers/condition/cls.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
query()
abstractmethod
Performs the condition check.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the condition is met, False otherwise. |
Source code in pipeline/handlers/condition/cls.py
59 60 61 62 63 64 65 66 67 | |
handlers.condition.registry
Condition
Registry for all condition handlers.
This class groups all available condition handlers (e.g., ValueType, MinLength, Equal) for easy access.
Source code in pipeline/handlers/condition/registry.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
DoesNotMatchField
Bases: ConditionHandler[Any, Any]
Validates that the current value does not match the value of another field in the context (e.g., new password != old password)
Source code in pipeline/handlers/condition/registry.py
170 171 172 173 174 175 176 177 178 179 180 181 | |
Equal
Bases: ConditionHandler[Any, Any]
Ensures the value is strictly equal to the argument or a specific context field
Source code in pipeline/handlers/condition/registry.py
135 136 137 138 139 140 141 142 143 144 145 | |
ExactLength
Bases: ConditionHandler[str | list | dict, int]
Ensures the collection or string is exactly N items/characters long
Source code in pipeline/handlers/condition/registry.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
IncludedIn
Bases: ConditionHandler[Any, Iterable]
Ensures the value exists within the provided Iterable
Source code in pipeline/handlers/condition/registry.py
111 112 113 114 115 116 117 118 119 120 121 122 | |
MatchesField
Bases: ConditionHandler[Any, Any]
Validates that the current value matches the value of another field in the context (e.g., password confirmation)
Source code in pipeline/handlers/condition/registry.py
158 159 160 161 162 163 164 165 166 167 168 | |
MaxLength
Bases: ConditionHandler[str | list | dict, int]
Ensures the collection or string does not exceed N items/characters
Source code in pipeline/handlers/condition/registry.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
MaxNumber
Bases: ConditionHandler[int | float, int | float]
Ensures the numeric value is less than or equal to N
Source code in pipeline/handlers/condition/registry.py
99 100 101 102 103 104 105 106 107 108 109 | |
MinLength
Bases: ConditionHandler[str | list | dict, int]
Ensures the collection or string has at least N items/characters
Source code in pipeline/handlers/condition/registry.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
MinNumber
Bases: ConditionHandler[int | float, int | float]
Ensures the numeric value is greater than or equal to N
Source code in pipeline/handlers/condition/registry.py
87 88 89 90 91 92 93 94 95 96 97 | |
NotEqual
Bases: ConditionHandler[Any, Any]
Ensures the value is strictly not equal to the argument or a specific context field
Source code in pipeline/handlers/condition/registry.py
147 148 149 150 151 152 153 154 155 156 | |
NotIncludedIn
Bases: ConditionHandler[Any, Iterable]
Ensures the value does not exist within the provided blacklist
Source code in pipeline/handlers/condition/registry.py
124 125 126 127 128 129 130 131 132 133 | |
Pipeline
Bases: ConditionHandler[dict, Pipeline]
Validates a dictionary using the same rules as the normal pipeline, but for nested data.
Source code in pipeline/handlers/condition/registry.py
183 184 185 186 187 188 189 190 191 192 193 194 | |
ValueType
Bases: ConditionHandler[Any, type]
A built-in condition handler to validate the type of the value.
This handler is automatically used by the Pipe to ensure the passed value matches the expected type defined in the Pipe.
Source code in pipeline/handlers/condition/registry.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
handlers.match.cls
MatchHandler
Bases: ConditionHandler[V, A]
Base class for match handlers.
Match handlers extend condition handlers to provide specific matching capabilities, often involving regular expressions or patterns.
Source code in pipeline/handlers/match/cls.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
fullmatch(pattern, flag=None)
Checks if the entire value matches the pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str | Pattern
|
The regex pattern to match against. |
required |
flag
|
RegexFlag | None
|
Optional regex flags. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the entire value matches the pattern, False otherwise. |
Source code in pipeline/handlers/match/cls.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
get_diacritics(languages, letter_case=None)
staticmethod
Retrieves a string of diacritic characters for the specified languages.
Combines all unique diacritic marks associated with a given set of ISO 639-1 language codes. The output can be filtered by letter case or return both cases by default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
languages
|
tuple[str, ...] | None
|
A tuple of ISO 639-1 language codes (e.g., ("fr", "de")). If None or empty, an empty string is returned. |
required |
letter_case
|
Literal['lower', 'upper'] | None
|
The desired grammatical case for the diacritics. Options are "lower", "upper", or None. If None, both cases are returned. This is a positional-only argument. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A string containing the concatenated diacritic characters for the |
str
|
requested languages and case. |
Source code in pipeline/handlers/match/cls.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
search(pattern, flag=None)
Searches for the pattern in the value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str | Pattern
|
The regex pattern to search for. |
required |
flag
|
RegexFlag | None
|
Optional regex flags. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the pattern is found, False otherwise. |
Source code in pipeline/handlers/match/cls.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
handlers.match.registry
Match
Central registry for all match handler units.
This class provides a convenient way to access different match handlers (e.g., Text, Regex, Web) from a single location.
Source code in pipeline/handlers/match/registry.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
MatchEncoding
Registry for encoding-related match handlers.
Includes handlers for Base64, JSON, etc.
Source code in pipeline/handlers/match/units/encoding.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
Base64
Bases: MatchHandler[str, None]
Checks if string is valid Base64 encoded
Source code in pipeline/handlers/match/units/encoding.py
15 16 17 18 19 20 21 22 23 24 25 26 | |
JSON
Bases: MatchHandler[str, None]
Validates that a string is a correctly formatted JSON object or array
Source code in pipeline/handlers/match/units/encoding.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
MatchFormat
Registry for format-related match handlers.
Includes handlers for Email, UUID, HexColor, etc.
Source code in pipeline/handlers/match/units/format.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
E164Phone
Bases: MatchHandler[str, None]
International phone numbers in E.164 format (e.g., +1234567890)
Source code in pipeline/handlers/match/units/format.py
54 55 56 57 58 59 60 61 62 63 64 65 | |
Email
Bases: MatchHandler[str, None]
Accepts email addresses with standard user, domain, and TLD parts
Source code in pipeline/handlers/match/units/format.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
HexColor
Bases: MatchHandler[str, None]
Accepts hex colors in 3 or 6 digit formats (e.g., #F00, #FF0000)
Source code in pipeline/handlers/match/units/format.py
42 43 44 45 46 47 48 49 50 51 52 | |
JWT
Bases: MatchHandler[str, None]
Validates the structure of a JSON Web Token (header.payload.signature)
Source code in pipeline/handlers/match/units/format.py
114 115 116 117 118 119 120 121 122 123 | |
Password
Bases: MatchHandler[str, str]
Validates password strength based on three policies: RELAXED, NORMAL, or STRICT.
Policies: - RELAXED: 6-64 chars, 1 uppercase, 1 lowercase. - NORMAL: 6-64 chars, 1 uppercase, 1 lowercase, 1 digit. - STRICT: 6-64 chars, 1 uppercase, 1 lowercase, 1 digit, 1 special character.
Requires a policy argument (e.g., Match.Format.Password.NORMAL)
Source code in pipeline/handlers/match/units/format.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
UUID
Bases: MatchHandler[str, None]
Validates 36-character hexadecimal unique identifiers (8-4-4-4-12)
Source code in pipeline/handlers/match/units/format.py
31 32 33 34 35 36 37 38 39 40 | |
MatchLocalization
Registry for localization-related match handlers.
Includes handlers for Country, Currency, Language (ISO codes), and Timezones.
Source code in pipeline/handlers/match/units/localization.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
Country
Bases: MatchHandler[str, None]
ISO 3166-1 alpha-2 (e.g., 'US', 'DE', 'JP')
Source code in pipeline/handlers/match/units/localization.py
18 19 20 21 22 23 24 25 26 27 28 29 | |
Currency
Bases: MatchHandler[str, None]
ISO 4217 (e.g., 'USD', 'EUR', 'BTC')
Source code in pipeline/handlers/match/units/localization.py
31 32 33 34 35 36 37 38 39 40 41 | |
Language
Bases: MatchHandler[str, None]
ISO 639-1 (e.g., 'en', 'fr', 'zh')
Source code in pipeline/handlers/match/units/localization.py
43 44 45 46 47 48 49 50 51 52 53 | |
Timezone
Bases: MatchHandler[str, None]
IANA Timezone (e.g., 'America/New_York', 'Europe/London')
Source code in pipeline/handlers/match/units/localization.py
55 56 57 58 59 60 61 62 63 64 65 66 | |
MatchNetwork
Registry for network-related match handlers.
Includes handlers for IPv4, IPv6, MAC Addresses, etc.
Source code in pipeline/handlers/match/units/network.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
IPv4
Bases: MatchHandler[str, None]
Validates a standard IPv4 address (e.g., '192.168.1.1')
Source code in pipeline/handlers/match/units/network.py
15 16 17 18 19 20 21 22 23 24 25 | |
IPv6
Bases: MatchHandler[str, None]
Validates an IPv6 address (e.g., '2001:db8::ff00:42:8329')
Source code in pipeline/handlers/match/units/network.py
27 28 29 30 31 32 33 34 35 36 37 | |
MACAddress
Bases: MatchHandler[str, None]
Accepts hardware MAC addresses using colon, hyphen, or dot separators
Source code in pipeline/handlers/match/units/network.py
39 40 41 42 43 44 45 46 47 48 49 50 | |
MatchRegex
Registry for regex-related match handlers.
Includes handlers for Search and FullMatch.
Source code in pipeline/handlers/match/units/regex.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
FullMatch
Bases: MatchHandler[str, str | Pattern]
Accepts values that match the provided regex pattern in their entirety
Source code in pipeline/handlers/match/units/regex.py
28 29 30 31 32 33 34 35 36 37 38 39 | |
Search
Bases: MatchHandler[str, str | Pattern]
Accepts values that contain at least one match of the provided regex pattern
Source code in pipeline/handlers/match/units/regex.py
15 16 17 18 19 20 21 22 23 24 25 26 | |
MatchText
Registry for text-related match handlers.
Includes handlers for Lowercase, Uppercase, Digits, etc.
Source code in pipeline/handlers/match/units/text.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
Alphanumeric
Bases: MatchHandler[str, tuple | None]
Accepts letters and digits if no diacritics are provided via tuple. No symbols or spaces.
Source code in pipeline/handlers/match/units/text.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
AlphanumericWithSpaces
Bases: MatchHandler[str, tuple | None]
Accepts letters, digits, and spaces if no diacritics are provided via tuple. No symbols.
Source code in pipeline/handlers/match/units/text.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
Digits
Bases: MatchHandler[str, None]
Accepts ONLY numeric digits (0-9)
Source code in pipeline/handlers/match/units/text.py
103 104 105 106 107 108 109 110 111 112 | |
DigitsWithSpaces
Bases: MatchHandler[str, None]
Accepts numeric digits (0-9) and spaces
Source code in pipeline/handlers/match/units/text.py
114 115 116 117 118 119 120 121 122 123 124 125 | |
Letters
Bases: MatchHandler[str, tuple | None]
Accepts ONLY English letters (a-z, A-Z) if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
LettersWithSpaces
Bases: MatchHandler[str, tuple | None]
Accepts English letters (a-z, A-Z) and spaces if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
Lowercase
Bases: MatchHandler[str, tuple | None]
Accepts ONLY lowercase English letters (a-z) if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
LowercaseWithSpaces
Bases: MatchHandler[str, tuple | None]
Accepts lowercase English letters (a-z) and spaces if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
NoWhitespace
Bases: MatchHandler[str, None]
Ensures string contains no spaces, tabs, or line breaks
Source code in pipeline/handlers/match/units/text.py
172 173 174 175 176 177 178 179 180 181 182 | |
Printable
Bases: MatchHandler[str, tuple | None]
Accepts ASCII (20-7E) and diacritics if provided via tuple.
Source code in pipeline/handlers/match/units/text.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
Slug
Bases: MatchHandler[str, None]
URL-friendly strings: 'my-cool-post-123'
Source code in pipeline/handlers/match/units/text.py
184 185 186 187 188 189 190 191 192 193 194 195 | |
Uppercase
Bases: MatchHandler[str, tuple | None]
Accepts ONLY uppercase English letters (A-Z) if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
UppercaseWithSpaces
Bases: MatchHandler[str, tuple | None]
Accepts uppercase English letters (A-Z) and spaces if no diacritics are provided via tuple.
Source code in pipeline/handlers/match/units/text.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
MatchTime
Registry for time-related match handlers.
Includes handlers for Date, Time, and DateTime (ISO 8601).
Source code in pipeline/handlers/match/units/time.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
Date
Bases: MatchHandler[str, None]
Validates YYYY-MM-DD format
Source code in pipeline/handlers/match/units/time.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
DateTime
Bases: MatchHandler[str, None]
Validates ISO 8601 combined Date and Time (e.g., 2023-10-01T14:30:00Z).
Source code in pipeline/handlers/match/units/time.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
Time
Bases: MatchHandler[str, None]
Validates 24h time in HH:MM or HH:MM:SS format
Source code in pipeline/handlers/match/units/time.py
28 29 30 31 32 33 34 35 36 37 38 | |
MatchWeb
Registry for web-related match handlers.
Includes handlers for Domain and URL.
Source code in pipeline/handlers/match/units/web.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
Domain
Bases: MatchHandler[str, None]
Validates a domain name based on RFC 1035.
Source code in pipeline/handlers/match/units/web.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |
URL
Bases: MatchHandler[str, None]
Validates web URLs using HTTP or HTTPS protocols.
Source code in pipeline/handlers/match/units/web.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
handlers.transform.cls
TransformHandler
Bases: BaseHandler[V, A]
Abstract base class for transform handlers.
Transform handlers modify the input value and return the transformed value.
They must implement the operation method.
Source code in pipeline/handlers/transform/cls.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
operation()
abstractmethod
Performs the transformation operation.
Returns:
| Name | Type | Description |
|---|---|---|
V |
V
|
The transformed value. |
Source code in pipeline/handlers/transform/cls.py
17 18 19 20 21 22 23 24 25 | |
handlers.transform.registry
Transform
Central registry for all transform handlers.
Transform handlers modify the value in some way, such as changing case, replacing substrings, or performing arithmetic operations.
Source code in pipeline/handlers/transform/registry.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
Apply
Bases: TransformHandler[Any, Callable]
Transforms the value by passing it through the provided callable.
The callable should take only one argument (the value) and return the transformed value. No checks are performed on the returned value, so ensure it meets your specific requirements.
Source code in pipeline/handlers/transform/registry.py
97 98 99 100 101 102 103 104 105 106 107 108 | |
Capitalize
Bases: TransformHandler[str, None]
Converts the first character to uppercase and the rest to lowercase
Source code in pipeline/handlers/transform/registry.py
23 24 25 26 27 28 | |
Lowercase
Bases: TransformHandler[str, None]
Converts all characters in the string to lowercase
Source code in pipeline/handlers/transform/registry.py
30 31 32 33 34 35 | |
Multiply
Bases: TransformHandler[str | list | int | float, int | float]
Multiplies a string, list, integer or float by the provided argument
If the value is not numeric, the argument is rounded before multiplication.
Source code in pipeline/handlers/transform/registry.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
Replace
Bases: TransformHandler[str, tuple]
Replaces all occurrences of a substring with another (old, new)
Source code in pipeline/handlers/transform/registry.py
88 89 90 91 92 93 94 95 | |
Reverse
Bases: TransformHandler[str | list, None]
Reverses the order of characters in a string or items in a list
Source code in pipeline/handlers/transform/registry.py
58 59 60 61 62 63 | |
SnakeCase
Bases: TransformHandler[str, None]
Converts strings to snake_case (e.g., 'HelloWorld' -> 'hello_world')
Source code in pipeline/handlers/transform/registry.py
72 73 74 75 76 77 78 79 | |
Strip
Bases: TransformHandler[str, str | None]
Removes leading and trailing whitespace from a string
Source code in pipeline/handlers/transform/registry.py
16 17 18 19 20 21 | |
Title
Bases: TransformHandler[str, None]
Converts the first character of every word to uppercase
Source code in pipeline/handlers/transform/registry.py
65 66 67 68 69 70 | |
Unique
Bases: TransformHandler[list, None]
Removes duplicate items from a list while preserving order
Source code in pipeline/handlers/transform/registry.py
81 82 83 84 85 86 | |
Uppercase
Bases: TransformHandler[str, None]
Converts all characters in the string to uppercase
Source code in pipeline/handlers/transform/registry.py
37 38 39 40 41 42 | |
integration.falcon.decorator
process_request(pre_hook=None, post_hook=None, teardown=None, handle_errors=None, **pipes_config)
A decorator factory that validates Falcon request (WSGI and ASGI) data using a defined pipeline.
This decorator extracts data from a Falcon Request object (either from
query parameters for GET requests or the media body for other methods),
runs it through a PipelineFalcon instance, and injects the validated
data into the decorated responder method.
If validation fails, it automatically sets the response body to the
validation errors and returns a 422 Unprocessable Content status, preventing
the responder from executing. You can use your own error handler via
PipelineFalcon.handle_errors, but it must end the request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pre_hook
|
PipelineHookFunc | None
|
A function to be called before each pipe execution. The global_pre_hook will not run if a local pre_hook is defined. |
None
|
post_hook
|
PipelineHookFunc | None
|
A function to be called after each pipe execution. The global_post_hook will not run if a local pre_hook is defined. |
None
|
teardown
|
PipelineTeardownFunc | None
|
A function that will run after the entire pipeline finishes execution. This runs before handle_errors and will execute even if the pipeline failed. The global_teardown will not run if a local teardown is defined. |
None
|
handle_errors
|
PipelineHandleErrorsFunc | None
|
A function to handle errors collected during pipeline execution. This could be used to raise exceptions, log errors, or format them for a response. The global_handle_errors will not run if a local handle_errors is defined. |
None
|
**pipes_config
|
PipeConfig
|
Configuration for the pipes. Keys represent the fields in the data dictionary to be processed, and values are the configuration for the corresponding pipe. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Callable |
A decorator that wraps a Falcon responder method. |
Example
@request_validator( email={ "type": str, "conditions": { Condition.MaxLength: 64 }, "matches": { Match.Format.Email: None } } ) def on_post(self, req, resp, email): pass
Source code in pipeline/integration/falcon/decorator.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
battery.cls
Battery
A centralized registry of reusable pipe configurations for DRY validation.
Battery serves as a collection of pre-built BatteryUnit instances that
represent common validation patterns (e.g., UUID, email, pagination limits).
These units can be registered statically as class attributes or added
dynamically at runtime, and then consumed anywhere in the application
via the sink() method.
Source code in pipeline/battery/cls.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
UUID = BatteryUnit(type=str, conditions={Condition.ExactLength: 36}, matches={Match.Format.UUID: None})
class-attribute
instance-attribute
A pre-built unit that validates a UUID v4 string.
add(name, **pipe_config)
classmethod
Registers a new BatteryUnit as a class attribute.
Creates a BatteryUnit from the provided pipe configuration and
assigns it to the class under the given name. This allows dynamically
extending the Battery registry at application startup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute name under which the unit will be stored on the class. |
required |
**pipe_config
|
PipeConfig
|
The pipe configuration for the new unit. |
{}
|
Source code in pipeline/battery/cls.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
get(name)
classmethod
Retrieves a registered BatteryUnit by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute name of the unit to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
The BatteryUnit instance registered under the given name. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If no unit with the given name has been registered on the class. |
Source code in pipeline/battery/cls.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
use_email(min_length=6, max_length=64)
staticmethod
Creates a BatteryUnit for email address validation.
Produces a unit that validates a string value as a well-formed email address within a configurable length range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_length
|
int
|
The minimum allowed length of the email address. Defaults to 6. |
6
|
max_length
|
int
|
The maximum allowed length of the email address. Defaults to 64. |
64
|
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
A unit for email validation. |
Source code in pipeline/battery/cls.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
use_limit(min_number=1, max_number=1000)
staticmethod
Creates a BatteryUnit for pagination limit validation.
Produces a unit that validates an integer value representing the number of items to return per page, within a configurable range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_number
|
int
|
The minimum allowed limit value. Defaults to 1. |
1
|
max_number
|
int
|
The maximum allowed limit value. Defaults to 1000. |
1000
|
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
A unit for pagination limit validation. |
Source code in pipeline/battery/cls.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
use_offset(min_number=0, max_number=1000)
staticmethod
Creates a BatteryUnit for pagination offset validation.
Produces a unit that validates an integer value representing the
starting position of a result set, within a configurable range.
Differs from use_limit only in its default min_number of 0,
which allows an offset of zero as a valid starting point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_number
|
int
|
The minimum allowed offset value. Defaults to 0. |
0
|
max_number
|
int
|
The maximum allowed offset value. Defaults to 1000. |
1000
|
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
A unit for pagination offset validation. |
Source code in pipeline/battery/cls.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
use_password(policy)
staticmethod
Creates a BatteryUnit for password validation.
Produces a unit that validates a string's length and, optionally, its complexity against predefined security patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
Literal['relaxed', 'normal', 'strict']
|
The complexity level. If None, only length is validated (min: 6, max: 64). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
A unit for password validation. |
Source code in pipeline/battery/cls.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
use_token(exact_length=32, digits_only=False)
staticmethod
Creates a BatteryUnit for token validation.
Produces a unit that validates a string as a fixed-length token. Can be configured for alphanumeric characters or strictly digits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exact_length
|
int
|
The required exact length of the token. Defaults to 32. |
32
|
digits_only
|
bool
|
If True, validates using Match.Text.Digits. If False, validates using Match.Text.Alphanumeric. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
BatteryUnit |
BatteryUnit
|
A unit for token validation. |
Source code in pipeline/battery/cls.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
battery.unit
BatteryUnit
A reusable container for a single pipe configuration.
Stores a pre-defined set of pipe arguments that can be retrieved and optionally extended at
the point of use via the sink() method.
Source code in pipeline/battery/unit.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
__init__(**pipe_config)
Initializes the BatteryUnit with a fixed pipe configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**pipe_config
|
PipeConfig
|
The pipe configuration to store. |
{}
|
Source code in pipeline/battery/unit.py
13 14 15 16 17 18 19 20 | |
sink(**update)
Returns the stored pipe configuration, optionally merged with overrides.
This method is the primary way to consume a BatteryUnit. It returns a
PipeConfig dictionary ready to be passed to a Pipe or Pipeline.
Any keyword arguments provided in update will overwrite the
corresponding keys in the stored configuration, allowing for
field-specific customization without modifying the original unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**update
|
PipeUpdateConfig
|
Optional overrides to merge into the stored configuration. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
PipeConfig |
PipeConfig
|
A merged dictionary of the stored configuration and any provided overrides. |
Source code in pipeline/battery/unit.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |