Pydantic Field constraint does not trigger with Optional type
I have a class with some attributes I want to constrain to a range.
I did this with pydantics’ Field constraint (e.g. ge=0), and expected the constraint to be enforced.
However, validation does not trigger as expected, and an invalid value is set. Here is a small working example:
Pydantic Field constraint does not trigger with Optional type
I have a class with some attributes I want to constrain to a range.
I did this with pydantics’ Field constraint (e.g. ge=0), and expected the constraint to be enforced.
However, validation does not trigger as expected, and an invalid value is set. Here is a small working example:
Pydantic Field constraint does not trigger with Optional type
I have a class with some attributes I want to constrain to a range.
I did this with pydantics’ Field constraint (e.g. ge=0), and expected the constraint to be enforced.
However, validation does not trigger as expected, and an invalid value is set. Here is a small working example: