Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use decorators for simple input validations #14721

@adrinjalali

Description

@adrinjalali

We have a lot of input validations on simple scalar inputs which can be handled with a decorator. It'd be less error prune and would simplify the code. Do we think that's a good idea?

Something like

@validate_input('threshold', min=0, max=1, type=[float, int],
    err_message='the message goes here')
def f(threshold=0.9):
    ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions