schema icon indicating copy to clipboard operation
schema copied to clipboard

Add decorators to the library so functions/methods param can be automatically validated or raise SchemaError if invalid.

Open bernalrs opened this issue 9 years ago • 2 comments

I would like to suggest the following feature of adding decorators to the library so functions/methods param can be automatically validated or raise SchemaError if invalid. This would allow to factor out the validation logic from within the method. If this sounds like a good idea more than happy to submit an implementation ?

bernalrs avatar Aug 05 '16 09:08 bernalrs

Hmm, could you write an example of how you think it should look? It sounds like a good idea but the implementation can get hairy.

skorokithakis avatar Aug 05 '16 09:08 skorokithakis

Hey @bernalrs , I ended up having the same idea today and had a first go, I put my initial snippets up at https://gist.github.com/MathieuDuponchelle/1c3b6c43b565e4c4a998a7f44e84fae3 .

While we certainly wouldn't want to do that kind of thing for every and all function in a program, it will certainly help me a lot in cleaning up input to python API I might be developing.

MathieuDuponchelle avatar Oct 28 '16 00:10 MathieuDuponchelle