fastmail / Ix

automatic generation of JMAP-style APIs
GNU General Public License v2.0
10 stars 5 forks source link

validate_args: a quick and dirty required-and-optional arg checker #96

Closed rjbs closed 6 years ago

rjbs commented 7 years ago

This isn't perfect, but it will be a quick way for lots of things to start off by saying "if there are unknown or missing arguments, just give up." Right now, we see this pattern repeated as too many identical-looking lines of code throughout different method handlers.

mmcclimon commented 7 years ago

One tiny comment, otherwise looks good.

wolfsage commented 7 years ago

I like it. Seems like something Ix should be able to use and auto-generate validators based on metadata... maybe...

wolfsage commented 7 years ago

I think one of the more dangerous elements is getting references when we expect strings. A type-enforcing validator would go a long way

rjbs commented 7 years ago

My plan is to have a future form where you can say:

{ required => { foo => $validator } }

...but I didn't want to get bogged down in that yet.

rjbs commented 7 years ago

Okay, I went and got bogged down in that. It's nice.

wolfsage commented 7 years ago

I like it.

rjbs commented 6 years ago

Applied.