Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark as required #41

Open
rightisleft opened this issue Nov 14, 2016 · 8 comments
Open

Mark as required #41

rightisleft opened this issue Nov 14, 2016 · 8 comments

Comments

@rightisleft
Copy link

It would be great if we could have a decorator that allowed use to mark a paramater as required during serialize/deserialize/auto

This would allow us to ensure that the contract is properly met.

@weichx
Copy link
Owner

weichx commented Nov 15, 2016

How would imagine this plays out?

class Thing {
   @autoseralizeAs(String, true) thing1 : string;
   //or
   @autoserializeRequired thing2 : string;

}

or something else? I like the idea, I'm unsure off the top of my head what the interface for that would look like

@Marche86
Copy link

Marche86 commented Nov 15, 2016

I prefer

@autoseralizeAs(String, true) thing1 : string;

Like java style

@autoseralizeAs(columnDefinition="string", required=true)

@rightisleft
Copy link
Author

or even just a seperate annotation

@required
@autoserialize

or require all and then opt out

@requireAll
export class Foo {

@autoserialize thing1
@autoserialize thing2
@autoserialize thing3
@autoserialize thing4

@optional
@autoserialize thing5
}

@rightisleft
Copy link
Author

Because interfaces are compile time only in typescript - i see a lot of 'loose' declarations where data could or could not be missing depending on the source.

Having auto runtime checking of all properties would be a huge win

@weichx
Copy link
Owner

weichx commented Nov 16, 2016

Yeah I agree. I think I prefer the separate annotation. I'll see what I can do about that, or feel free to submit a PR since it will take me a few days before I have time to look at this seriously

@rightisleft
Copy link
Author

Happy to test it when its ready! I definitely dont have the bandwidth

@hwaterke
Copy link

Any news on the proposal?
This would allow me to drop all my PropTypes (React) that I'm still keeping for the runtime checks

@weichx
Copy link
Owner

weichx commented Jan 28, 2017

No no update yet, haven't had the time unfortunately. feel free to submit a PR though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants