-
-
Notifications
You must be signed in to change notification settings - Fork 318
[bug] Validator only casts default value #834
Copy link
Copy link
Closed
Labels
Milestone
Description
Describe the bug
The Validator cast function only casts the default value, if provided.
If the default value is erased, and then the validator is called to be validated, the cast doesn't happen as it should be.
To Reproduce
Steps to reproduce the behavior:
3. Having the following app code:
Code
/path/src/app.py
from dynaconf import Dynaconf, Validator
settings = Dynaconf(
validators=[
Validator("offset", default=1, cast=int)
]
)
settings.offset = '24'
settings.validators.validate()
print(type(settings.offset))
...Expected behavior
The output should have been:
<class 'int'>Actual behavior
<class 'str'>Environment (please complete the following information):
- OS: Ubuntu 20.04
- Dynaconf Version
3.1.11
This is unfortunately a major blocker for me as I would like to do advanced parsing, conversion and validation through the cast callable.
Reactions are currently unavailable