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

Excellent pydantic support for sized containers #111

Closed
2 tasks done
antonagestam opened this issue Jun 12, 2021 · 2 comments
Closed
2 tasks done

Excellent pydantic support for sized containers #111

antonagestam opened this issue Jun 12, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@antonagestam
Copy link
Owner

antonagestam commented Jun 12, 2021

Currently there are two issues:

@antonagestam antonagestam added blocked This issue isn't currently actionable due to some external circumstance enhancement New feature or request labels Jun 15, 2021
@flaeppe
Copy link
Contributor

flaeppe commented Nov 29, 2021

Not sure if I'm running in to the mentioned Caveat regarding pydantic and NonEmpty below? Or is it a separate issue I'm running in to? (Feels a little bit like I'm running in to some problem with sub-field type not being available)

from phantom.sized import NonEmpty
from pydantic import BaseModel

class M(BaseModel):
    x: NonEmpty[list[str]]

M(x=["abc"])

This is the error I get:

pydantic.error_wrappers.ValidationError: 1 validation error for M
x
  Could not parse phantom.sized.NonEmpty from ['abc'] (type=type_error)

@antonagestam
Copy link
Owner Author

@flaeppe The documented caveat is only regarding JSON schema validation, e.g. minItems, maxItems and items.type aren't automatically set.

I think you will want to use NonEmpty[str] and not NonEmpty[list[str]], there's related discussion in this issue: #160

@antonagestam antonagestam removed the blocked This issue isn't currently actionable due to some external circumstance label Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants