Adding SomeOf validator#314
Conversation
| class SomeOf(object): | ||
| """Value must pass at least some validations, determined by the given parameter | ||
|
|
||
| The output of each validator is passed as input to the next. |
There was a problem hiding this comment.
description will be improved in the next update of this PR (I'm sure there will be so I'm waiting with pushing it 😄 )
There was a problem hiding this comment.
Haha.. Let's not rely on it.
|
Is this repository not active anymore? |
|
Hey @guyarad I was busy over the weekends. Will review it and get back to you. Before my review, please fix the failing tests. Thanks. |
|
@tusharmakkar08 no rush - just wanted to know how active we are 😊 the failing tests aren't mine. they seem to exist after the last commit to master. |
tusharmakkar08
left a comment
There was a problem hiding this comment.
Please look into the comments.
| """ | ||
|
|
||
| def __init__(self, min_valid, validators, max_valid=None, **kwargs): | ||
| self.min_valid = min_valid or 0 |
There was a problem hiding this comment.
Why min_valid is not a default keyword argument while max_valid is?
There was a problem hiding this comment.
Originally I only needed "minimum valid schemas" and just added "max valid" for completeness. So for me, min_valid was always needed. We can put them both as optional, and assert that either of them has a value (otherwise, what's the point of this validator).
Sounds good?
| 3.6.3 | ||
| 3.3.6 | ||
| 3.4.7 | ||
| 3.5.2 |
There was a problem hiding this comment.
this file was accidentally added because I was working with pyenv which proved to be very useful for testing locally with multiple python versions.
I was going to remove it, but then thought it would be a good to have such convention as repository users, to use pyenv. your call.
There was a problem hiding this comment.
@alecthomas What do you think about adding this to the package?
There was a problem hiding this comment.
Let's remove this for now and create an issue where we will continue this discussion.
| validator('3A34SDEF5') | ||
|
|
||
|
|
||
| def test_SomeOf_max_validation(): |
There was a problem hiding this comment.
Let's add a test for checking the assert statement too using AssertionError
| 3.6.3 | ||
| 3.3.6 | ||
| 3.4.7 | ||
| 3.5.2 |
There was a problem hiding this comment.
@alecthomas What do you think about adding this to the package?
The SomeOf validator can verify that some of validators are met, or optionally at most number of validators.