pydantic-core
pydantic-core copied to clipboard
Support `FutureDate/Datetime` and `PastDate/Datetime`
This will require us to add support for now()
and today()
to speedate, see https://github.com/pydantic/speedate/issues/19.
Required to for https://github.com/pydantic/pydantic/issues/4330.
I think I don't understand why it's needed. Doesn't
SchemaValidator(
{
'type': 'typed-dict',
'fields': {
'future_datetime': {
'schema': {'type': 'datetime', 'gt': datetime.now()},
},
},
}
)
already tackle this issue?
no because we create the schema once and use it many times, perhaps days later.
Right...sorry not enough sleep! 🤦
And what would be the desired API? A FutureDatetimeSchema
with only le
and lt
as constraints?
Or do we allow "magic" strings as boundaries (e.g. le: 'today'
)? They could also probably be sentinels
Well FutureDate
, Datetime
, PastDate
and Datetime
can all be bear types, no further configuration is required.
We'll also want condatetime
etc., but we're also going to support the annotated-types allowing
class MyClass:
ts: Annotated[datetime, Gt(datetime(2022, 8, 30, 12, 0))]