erhosen-libs / pydjantic

Use Pydantic Settings in your Django application.
MIT License
37 stars 9 forks source link

Improve failure output #10

Closed estahn closed 1 year ago

estahn commented 2 years ago

I receive the following failure output:

SECRET_KEY
  field required (type=value_error.missing)

The SECRET_KET config looks as follows:

SECRET_KEY: str = Field(default=Undefined, env='DJANGO_SECRET_KEY')

Given I'm using environment variables to pass in the configuration I can not discern the issue from looking at the output, e.g. I don't know I have to provide a value in DJANGO_SECRET_KEY until looking into the code.

Would it be possible to provide more details, possibly the entire config for this field? I see there are title and description available, which could be helpful too:

SECRET_KEY: str = Field(default=Undefined, env='DJANGO_SECRET_KEY', title="Secret key", description="lorem ipsum...")

Possible solution:

SECRET_KEY
  Error: field required (type=value_error.missing)
  Title: Secret Key
  Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed suscipit, orci
      nec facilisis tristique, nibh leo pretium mi, sed consequat nibh magna sit amet elit. Maecenas
      tempus porta tellus eu feugiat. Phasellus eget vehicula libero. Donec eget augue
      pellentesque, condimentum elit sed, lobortis est. Fusce eu risus placerat, mollis dolor at,
      convallis mi.
  Env: DJANGO_SECRET_KEY
erhosen commented 2 years ago

Thank you, I will think about it

l1b3r commented 2 years ago

While I appreciate the usefulness of the request, I think it should be addressed to Pydantic directly as it is the thing which is performing the heavy-lifting of validation and prints the output you are referring to.

erhosen commented 1 year ago

^