@@ -34,20 +34,22 @@ attributes in the middle of function execution.
34
34
3 . Usage of a third-party library called ` marshmallow ` .
35
35
4 . Combined option including a third-party library called ` typeguard ` , and
36
36
usage of python descriptors.
37
+ 5 . Combined option including a third-party library called ` typeguard ` , and
38
+ usage of ` ValidationMixin `
37
39
38
40
## Pros, Cons, and Considerations of the Options
39
41
40
42
Here is how all of our options compare against our requirements:
41
43
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 | ✓ | ✓ | ✓ | ✘ | ✓ |
51
53
52
54
Bellow, in the following sections, there are additional pros, cons, and
53
55
considerations for each of the options.
@@ -306,6 +308,14 @@ u._NO_VALIDATION_id = -100 # No validation will be invoked.
306
308
print (u.id)
307
309
```
308
310
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.
309
319
310
320
# # Links
311
321
* [in - toto ValidatorMixin](https:// github.com/ in - toto/ in - toto/ blob/ 74da7a / in_toto/ models/ common.py# L27-L40)
0 commit comments