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

Validation definition by using decorators. #4

Open
shiwano opened this issue Nov 11, 2015 · 3 comments
Open

Validation definition by using decorators. #4

shiwano opened this issue Nov 11, 2015 · 3 comments

Comments

@shiwano
Copy link
Owner

shiwano commented Nov 11, 2015

This is just a note.

typhen-json-schema's d.ts that exported by typings field of the package.json:

declare function minimum(min: number): PropertyDecorator;
declare var exclusiveMinimum: PropertyDecorator;

User's d.ts:

import {validation} from "typhen-json-schema";

class Product {
  @@validation.minimum(0)
  @@validation.exclusiveMinimum
  price: number;
}

Will be generated like this:

"price": {
  "minimum": 0,
  "exclusiveMinimum": true,
  "type": "number"
}
@horiuchi
Copy link
Contributor

@shiwano That's good idea 👍

@shiwano
Copy link
Owner Author

shiwano commented Nov 13, 2015

@horiuchi Thanks, I will do it. 😀

@shiwano
Copy link
Owner Author

shiwano commented Sep 8, 2016

Memo: microsoft/TypeScript#2900

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

2 participants