Skip to content

[Question] Is it possible to get all validation errors in one exception ? #754

@jidey43

Description

@jidey43

I want to write a Python script that validate given configs file in my production server pre-deployment.
My implementation is working, but the raised ValidationError holds only the first encountered error.
What I want is to provide feedback in the console about all the keys that did not pass the validation.

I don't want to use the provided CLI because the script is doing a global check on the projet and I want config validation be a part of it.

My code looks like this :

    # Validate config
    try:
        from config import config
        # Trigger lazy loading
        config._setup()
    except ValidationError as e:
        click.echo("Error occurred when validating settings files")
        click.echo(str(e))
        sys.exit(1)

If this is not possible, can I propose an implementation with a PR ?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions