Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug: Imperative Factory Creation doesn't respect pydantic Field constrains #617

Open
idan-rahamim-lendbuzz opened this issue Dec 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@idan-rahamim-lendbuzz
Copy link

idan-rahamim-lendbuzz commented Dec 4, 2024

Description

I have this pydantic model:
image

I have this base factory:
image

When i create a factory, it does not respect the pydantic Field constrains:

image

Release Version

2.18.1

@idan-rahamim-lendbuzz idan-rahamim-lendbuzz added the bug Something isn't working label Dec 4, 2024
@adhtruong
Copy link
Collaborator

This is expected behaviour.

When overriding fields, the constraints for type are not longer used. I desired you would need to pass the constraints to faker method or transform the output of the method.

@idan-rahamim-lendbuzz
Copy link
Author

idan-rahamim-lendbuzz commented Dec 5, 2024

This is expected behaviour.

When overriding fields, the constraints for type are not longer used. I desired you would need to pass the constraints to faker method or transform the output of the method.

If i don't want to specify the constrains again besides the pydantic field, is the only option would be to create a declerative factory for the specific model like the pic below? (I see it does respect the Field constrains)
And that means i will not be able to use imperative creation?

image

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants