[BUG] Query(regex) does not work for date types
See original GitHub issueDescribe the bug I would like to be able to make some data filter by GET parameter which is date
/api/foo?from_date=2019-01-01
And I want specifically it to be in YYYY-MM-DD format
To Reproduce
Steps to reproduce the behavior:
1.
I made the following parameter with query and regex:
def filter_order(from_date: date = Query(..., regex=r'\d{4}-\d{2}-\d{2}')
Expected behavior
when i query /api/foo?from_date=1
I expect a validation error
instead my date is valid and equal to date(1970, 1, 1)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Why is my regular expression for a valid date not working?
Currently, I am creating my own regular expression using JavaScript to test for a date in the format of MM-DD-YYYY. Here is my...
Read more >BigQuery Regex and Pattern Matching: 6 Major Things
2) BigQuery Regex: RegexP_EXTRACT If the expression doesn't find any match, it returns NULL. RegexP_EXTRACT returns an error if:
Read more >String functions | BigQuery - Google Cloud
In the following query, an error is thrown because the search value cannot be a literal NULL . ... DATE, FORMAT('%t', date '2015-09-01'),...
Read more >GREL functions - OpenRefine
If a function can take more than one kind of data as input or can output ... Takes any value type (string, number,...
Read more >Regular expressions in grep ( regex ) with examples - nixCraft
How do I use grep and regular expressions (regex)to search for text/ ... Regular Expressions is nothing but a pattern to match for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vitalik if you use a
date
ordatetime
type, then Pydantic uses it to handle data parsing. And anything you pass toQuery()
is used only for documentation.If you use
str
, then theregex
inQuery(..., regex="")
is used for documentation AND regex.If you want to have something constrained to some types of dates only, you could declare the parameter as
str
with the regex. And then if you want to have a date from it, you could put that in a dependency.E.g.
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.