【发布时间】:2022-08-18 17:56:31
【问题描述】:
from pydantic import BaseModel
class User(BaseModel):
age: int = Field(\'foo\', ge=0)
User() # doesn\'t raise an error
# User(age=\'foo\')
为什么这不会引发错误,因为字符串 foo 被传递,即使 int 是预期的?
User(age=\'foo\') 但是按预期提高了ValidationError。