Skip to content

Commit b9e838a

Browse files
committed
Document using typeguard and ValidationMixin
Signed-off-by: Martin Vrachev <[email protected]>
1 parent ca70f30 commit b9e838a

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

docs/adr/0007-validation-guideliness.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ attributes in the middle of function execution.
3434
3. Usage of a third-party library called `marshmallow`.
3535
4. Combined option including a third-party library called `typeguard`, and
3636
usage of python descriptors.
37+
5. Combined option including a third-party library called `typeguard`, and
38+
usage of `ValidationMixin`
3739

3840
## Pros, Cons, and Considerations of the Options
3941

4042
Here is how all of our options compare against our requirements:
4143

42-
| Number | Requirement | ValidationMixin | pydantic | marshmallow | typeguard + Descriptors |
43-
| ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
44-
| 1 | Validate function args everywhere | Limited || Limited ||
45-
| 2 | Custom deeper validation |||||
46-
| 3 | Performance overhead | Minimal | [Fastest](https://pydantic-docs.helpmanual.io/benchmarks/) | [Slower](https://pydantic-docs.helpmanual.io/benchmarks/) | No information |
47-
| 4 | Number of new depedencies | 0 | 2 | 1 | 1 |
48-
| 5 | Support for all python versions |||||
49-
| 6 | Code reuse for validation |||||
50-
| 7 | Way to invoke all validators |||||
44+
| Number | Requirement | ValidationMixin | pydantic | marshmallow | typeguard + Descriptors | typeguard + ValidationMixin |
45+
| ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
46+
| 1 | Validate function args everywhere | Limited || Limited |||
47+
| 2 | Custom deeper validation ||||||
48+
| 3 | Performance overhead | Minimal | [Fastest](https://pydantic-docs.helpmanual.io/benchmarks/) | [Slower](https://pydantic-docs.helpmanual.io/benchmarks/) | No information | No information |
49+
| 4 | Number of new depedencies | 0 | 2 | 1 | 1 | 1 |
50+
| 5 | Support for all python versions ||||||
51+
| 6 | Code reuse for validation || ||||
52+
| 7 | Way to invoke all validators ||||||
5153

5254
Bellow, in the following sections, there are additional pros, cons, and
5355
considerations for each of the options.
@@ -306,6 +308,14 @@ u._NO_VALIDATION_id = -100 # No validation will be invoked.
306308
print(u.id)
307309
```
308310

311+
### Option 5: Third-party library called `typeguard` and `ValidationMixin`
312+
313+
* All pros, cons, and consideration from option 1 are applied here too,
314+
with the exception that we can validate function arguments everywhere because
315+
of `typeguard`.
316+
317+
* All pros, cons, and consideration from option 4 related to `typeguard` apply
318+
here too.
309319

310320
## Links
311321
* [in-toto ValidatorMixin](https://github.com/in-toto/in-toto/blob/74da7a/in_toto/models/common.py#L27-L40)

0 commit comments

Comments
 (0)