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

Add validation as metadata on the schema #681

Open
woile opened this issue Jul 18, 2024 · 0 comments
Open

Add validation as metadata on the schema #681

woile opened this issue Jul 18, 2024 · 0 comments

Comments

@woile
Copy link
Contributor

woile commented Jul 18, 2024

Is your feature request related to a problem? Please describe.
The problem is how to share validation information as part of the schema.

What do I mean by validation?
mix_length or max_length on a string, or a regex pattern.

Describe the solution you'd like
dataclasses-avroschema es now able to add some metadata, my proposed solution is to also add the Field info from pydantic as part of the schema's metadata.

For example this schema, should include as part of the field's metadata also the min_length and pattern, etc:

from pydantic import BaseModel, Field


class Foo(BaseModel):
    short: str = Field(min_length=3)
    long: str = Field(max_length=10)
    regex: str = Field(pattern=r'^\d*$') 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant