jayphelps / core-decorators

Library of stage-0 JavaScript decorators (aka ES2016/ES7 decorators but not accurate) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic.
MIT License
4.52k stars 263 forks source link

Decorators for validations #141

Open varunkumar opened 6 years ago

varunkumar commented 6 years ago

Is there any plan to add decorators for performing various validations - type checks, null checks, custom checks on properties? Does it make sense to have them as part of this collection?

I would be happy to contribute if this seems fit and has potential interests.

jayphelps commented 6 years ago

No plans, but we can definitely discuss them! I think let's start with describing some concrete examples (with pseudo code) then we can go from there to see if they'd be a good fit.

As a guiding principle: the overall goal of core-decorators right now is mostly to implement decorators for fundamental things. The sort of decorators you might expect to be available by default in JavaScript, but aren't. It's not a strict definition though, if a given decorator is provides enough convenience and utility to be included. 😄

cosmocochrane1 commented 6 years ago

@jayphelps I found a case where I wanted to validate the Type of an argument passed into a method. Would this be something you'd be into having a look at. I'd be stoked to try to contribute