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

Property-decorator and typescript union types #104

Open
Manusan42 opened this issue Oct 9, 2017 · 2 comments
Open

Property-decorator and typescript union types #104

Manusan42 opened this issue Oct 9, 2017 · 2 comments
Assignees
Milestone

Comments

@Manusan42
Copy link

Hi,
short question: How do I map an union type like:

interface A {
  property: string | string[];
}

to the @Property-decorator validation type for model implementation?

@notheotherben
Copy link
Member

Hi @Manusan42 - I'm afraid this is a known limitation of the current @Property validation engine and something that I intend to address before v8.x is fully released. You can take a look at #97 for another request there if you are curious, but the current solution would be implementing a custom validation plugin which handles this for you.

@notheotherben notheotherben added this to the Version 8 milestone Oct 10, 2017
@notheotherben notheotherben self-assigned this Oct 10, 2017
@Manusan42
Copy link
Author

Manusan42 commented Oct 10, 2017

Ok, if I'm in higher need for this, I look into the custom validation. Till then I just use the @Property with required-flag only.

It would be sooooo cool if v8 of Iridium can handle just any interface declaration (with union or intersection types) directly given to the @Property like requested in Issue #81.

Edit: No, even better: To use the model validation just like the interface itself, it would be the most easiest way (for the user) to simply give the interface (which the model implements) into an decorator for the whole model or something similar which automates the model creation by interface process to eliminate any redundancy.

I hope you find some time in near future and thanks again for the fast reply.

Best regards

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

No branches or pull requests

2 participants