Skip to content
Discussion options

You must be logged in to vote

So, the solution is to use allow_inf_nan=False in ether Field (also Query, Form, ...)

class DataModel(BaseModel):
    a_string_value: str
    a_float_value: float = Field(allow_inf_nan=False)

or in model_config:

class DataModel(BaseModel):
    model_config = ConfigDict(allow_inf_nan=False)
    a_string_value: str
    a_float_value: float

Agree that it would be nice to add a Note in docs about this

Replies: 9 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@JavierSanchezCastro
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SamVermeulen42
Comment options

Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
6 participants
Converted from issue

This discussion was converted from issue #4589 on February 27, 2023 22:01.