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

Fix #1055 allow multiple validators with cast for the same field #1080

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

rochacbruno
Copy link
Member

from dynaconf import Dynaconf
from dynaconf import Validator

settings = Dynaconf(var="dynaconf")

def a(v):
    print("called a, replace conf -> settings")
    return v.replace("conf", "settings")

def b(v):
    print("called b, transform to upper DYNASETTINGS")
    return v.upper()

validators = [
    Validator("var", cast=a),
    Validator("var", cast=b),
]

settings.validators.register(*validators)
settings.validators.validate_all()

assert settings.var == "DYNASETTINGS", settings.var

Fix #1055

@rochacbruno rochacbruno added this to the 3.3.0 milestone Mar 22, 2024
@rochacbruno rochacbruno self-assigned this Mar 22, 2024
Copy link

netlify bot commented Mar 22, 2024

Deploy Preview for dynaconf ready!

Name Link
🔨 Latest commit 3f4c41a
🔍 Latest deploy log https://app.netlify.com/sites/dynaconf/deploys/660171a90bc0c4000860aed4
😎 Deploy Preview https://deploy-preview-1080--dynaconf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Mar 22, 2024

Test Results (Python 3.10)

475 tests  ±0   475 ✔️ ±0   34s ⏱️ -1s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit 3f4c41a. ± Comparison against base commit b528e92.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Mar 22, 2024

Test Results (Python 3.8)

475 tests  ±0   475 ✔️ ±0   35s ⏱️ +3s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit 3f4c41a. ± Comparison against base commit b528e92.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Mar 22, 2024

Test Results (Python 3.11)

475 tests  ±0   475 ✔️ ±0   34s ⏱️ -2s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ±0 

Results for commit 3f4c41a. ± Comparison against base commit b528e92.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Mar 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.75%. Comparing base (b528e92) to head (3f4c41a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1080   +/-   ##
=======================================
  Coverage   98.75%   98.75%           
=======================================
  Files          23       23           
  Lines        2248     2249    +1     
=======================================
+ Hits         2220     2221    +1     
  Misses         28       28           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pedro-psb pedro-psb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

docs/validation.md Show resolved Hide resolved
```python
from dynaconf import Dynaconf
from dynaconf import Validator

settings = Dynaconf(var="dynaconf")

def a(v):
    print("called a, replace conf -> settings")
    return v.replace("conf", "settings")

def b(v):
    print("called b, transform to upper DYNASETTINGS")
    return v.upper()

validators = [
    Validator("var", cast=a),
    Validator("var", cast=b),
]

settings.validators.register(*validators)
settings.validators.validate_all()

assert settings.var == "DYNASETTINGS", settings.var
```

Fix #1055
@pedro-psb pedro-psb merged commit b4bb2b5 into master Mar 25, 2024
48 checks passed
@pedro-psb pedro-psb deleted the 1055 branch March 25, 2024 17:08
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

Successfully merging this pull request may close these issues.

Multiple cast validators get discarded
2 participants