-
Notifications
You must be signed in to change notification settings - Fork 102
[feature] all() validator #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
e50acc6
7bbdbb5
389d85d
6cfa238
da27023
48b4865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| number_range: all(num(min=5), num(max=10)) | ||
| password: all(str(min=8), regex('^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).*$')) | ||
| email: all(str(), regex('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$')) | ||
| mixed_list: list(all(num(min=0), num(max=100))) | ||
| nested: | ||
| value: all(int(min=10), int(max=20)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like each of these can be accomplished without
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree the examples in the tests might give the impression that all() is redundant with existing validators. My goal with those cases was more to confirm that the implementation was working correctly and integrating cleanly with the existing system, rather than to showcase complex validation logic.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. To be clear, I don't think it's necessary to "showcase complexity", but rather to demonstrate utility. I agree there's a use case here involving composition of custom validators -- thanks for adding that to the README. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| number_range: 12 # Over max limit | ||
| password: "pass" # Too short and missing required characters | ||
| email: "invalid-email" # Not a valid email format | ||
| mixed_list: | ||
| - 42 | ||
| - 150 # Over max limit | ||
| - 15 | ||
| nested: | ||
| value: 5 # Under min limit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| number_range: 7 | ||
| password: "Password123" | ||
| email: "test@example.com" | ||
| mixed_list: | ||
| - 42 | ||
| - 78 | ||
| - 15 | ||
| nested: | ||
| value: 15 |
Uh oh!
There was an error while loading. Please reload this page.