{"action":"created","issue":{"url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/375","repository_url":"https://api.github.com/repos/Romakita/ts-express-decorators","labels_url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/375/labels{/name}","comments_url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/375/comments","events_url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/375/events","html_url":"https://github.com/Romakita/ts-express-decorators/issues/375","id":326883609,"node_id":"MDU6SXNzdWUzMjY4ODM2MDk=","number":375,"title":"Custom controller method parameter validation and conversion?","user":{"login":"unicreators","id":27564170,"node_id":"MDQ6VXNlcjI3NTY0MTcw","avatar_url":"https://avatars0.githubusercontent.com/u/27564170?v=4","gravatar_id":"","url":"https://api.github.com/users/unicreators","html_url":"https://github.com/unicreators","followers_url":"https://api.github.com/users/unicreators/followers","following_url":"https://api.github.com/users/unicreators/following{/other_user}","gists_url":"https://api.github.com/users/unicreators/gists{/gist_id}","starred_url":"https://api.github.com/users/unicreators/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unicreators/subscriptions","organizations_url":"https://api.github.com/users/unicreators/orgs","repos_url":"https://api.github.com/users/unicreators/repos","events_url":"https://api.github.com/users/unicreators/events{/privacy}","received_events_url":"https://api.github.com/users/unicreators/received_events","type":"User","site_admin":false},"labels":[{"id":677953609,"node_id":"MDU6TGFiZWw2Nzc5NTM2MDk=","url":"https://api.github.com/repos/Romakita/ts-express-decorators/labels/blocker","name":"blocker","color":"b60205","default":false},{"id":329676967,"node_id":"MDU6TGFiZWwzMjk2NzY5Njc=","url":"https://api.github.com/repos/Romakita/ts-express-decorators/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-28T03:18:30Z","updated_at":"2018-06-16T01:06:13Z","closed_at":null,"author_association":"NONE","body":"@Romakita \r\nIs there any way to do that?\r\n\r\n```js\r\n@Controller('/items')\r\nexport class ItemController {\r\n    constructor(private itemService: ItemService) {\r\n    }\r\n\r\n    @Get('/:id')\r\n    async get(\r\n        @PathParams('id',\r\n            Required([...], (...) => new CustomError(...)),\r\n            Type([Number, ...], (...) => new CustomError(...)),\r\n            // ...\r\n            (val) => { if (val == 5) throw new CustomError(...); return val + 1; })\r\n        id: number) {\r\n        return await this.itemService.getItem(id);\r\n    }\r\n}\r\n```\r\n\r\n// CUSTOM\r\n```js\r\n\r\n// my custom\r\nexport Range(min: number, max: number, customError: Function){\r\n        return (val) => {\r\n            if(val > min || val < max) throw customError(val);\r\n            return val;\r\n        };\r\n}\r\n\r\n@Controller('/items')\r\nexport class ItemController {\r\n    constructor(private itemService: ItemService) {\r\n    }\r\n\r\n    @Get('/:id')\r\n    async get(\r\n        @PathParams('id',\r\n            // use my custom\r\n            Range(1, 10, (...) => new CustomError(...)))\r\n        id: number) {\r\n        return await this.itemService.getItem(id);\r\n    }\r\n}\r\n\r\n```\r\n\r\nWhat do you think?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/comments/397775485","html_url":"https://github.com/Romakita/ts-express-decorators/issues/375#issuecomment-397775485","issue_url":"https://api.github.com/repos/Romakita/ts-express-decorators/issues/375","id":397775485,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Nzc3NTQ4NQ==","user":{"login":"unicreators","id":27564170,"node_id":"MDQ6VXNlcjI3NTY0MTcw","avatar_url":"https://avatars0.githubusercontent.com/u/27564170?v=4","gravatar_id":"","url":"https://api.github.com/users/unicreators","html_url":"https://github.com/unicreators","followers_url":"https://api.github.com/users/unicreators/followers","following_url":"https://api.github.com/users/unicreators/following{/other_user}","gists_url":"https://api.github.com/users/unicreators/gists{/gist_id}","starred_url":"https://api.github.com/users/unicreators/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unicreators/subscriptions","organizations_url":"https://api.github.com/users/unicreators/orgs","repos_url":"https://api.github.com/users/unicreators/repos","events_url":"https://api.github.com/users/unicreators/events{/privacy}","received_events_url":"https://api.github.com/users/unicreators/received_events","type":"User","site_admin":false},"created_at":"2018-06-16T01:06:13Z","updated_at":"2018-06-16T01:06:13Z","author_association":"NONE","body":"@Romakita \r\nI think it can simplify API complexity and scalability. "}}
{"actor":{"display_login":"unicreators"}}