Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submodel validation doesn't check the model is of the correct type #403

Closed
samuelcolvin opened this Issue Feb 19, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@samuelcolvin
Copy link
Owner

samuelcolvin commented Feb 19, 2019

pydantic/pydantic/main.py

Lines 410 to 417 in 7cd423a

def validate(cls, value: Union['DictStrAny', 'BaseModel']) -> 'BaseModel':
if isinstance(value, dict):
return cls(**value)
elif isinstance(value, BaseModel):
return value.copy()
else:
with change_exception(DictError, TypeError, ValueError):
return cls(**dict(value))

as of #389 I think any model will be permitted to a submodel field.

@samuelcolvin samuelcolvin added the bug label Feb 19, 2019

samuelcolvin added a commit that referenced this issue Feb 25, 2019

@samuelcolvin samuelcolvin referenced this issue Feb 25, 2019

Merged

submodel validation #407

3 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.