Skip to content

Consistent return type for .validate()? #155

@ytrepus

Description

@ytrepus

Hello,

It seems a little awkward for .validate to return a single boolean True when the configspec is validated, but a dict when there is an error (especially since the non-empty dict is evaluated as True which can be misleading). Almost feels like there should be a .validate that is always boolean, False if any one of the validations failed, and then a validate.detail or something that always has a dict with {field: validation result}, even if the validation is all True.

Also is it possible to replace values where validate failed with a default as specified in the configspec? I'm currently doing this manually by iterating over the .validate if validate is not True (which is what prompted the above).

If any of this is user error, my apologies; I am new to the library (but finding it very helpful so far!)

Thanks a lot,
Rob

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions