Open Leobouloc opened 9 months ago
@Leobouloc you're right. polyfactory
does not currently parse the Config
object for constraints and unfortunately, it seems pydantic
doesn't inject any of the constraints into the model fields that we do parse :/
Could this be solved by adding min_length
and max_length
parameters to from_model_field
and from_field_info
and passing cls.__model__.__config__.min_anystr_length
on to the constraints ? (I see that allow_population_by_field_name
is already being parsed from from the model Config
) ?
Are there some other constraints I am missing ?
I'm so sorry @Leobouloc, I had missed your question!
I think the right way to do this would be to for the from_model_field
and from_field_info
to consider the values in the config. I'm not sure about all the different constraints that can be set via the config, but all of them should be considered when creating the FieldMeta
.
Description
In a Pydantic model, when using
Config
fieldmin_anystr_length
(to set a minimum length for all strings in the model), Polyfactory does not seem to take it into account which leads to pydantic validation errors during build.My understanding is that currently, Polyfactory only parses the
allow_population_by_field_name
(here) from theConfig
.Is this assessment correct ? Thank you for your help !
URL to code causing the issue
No response
MCVE
Steps to reproduce
Screenshots
No response
Logs
Release Version
2.12.0
Platform