feat: IsPort decorator should accept number value
See original GitHub issueI was trying to…
class Config {
@IsPort()
port: number;
}
const c = new Config();
c.port = 3000;
console.log(validateSync(c)) // error occurred
The problem: validateSync returns an error in the above snippet. The error doesn’t appear when port type is string. Is this behavior intended? https://github.com/typestack/class-validator/blob/60f72a829da5b7669b852b96e4764ed525d772c3/src/decorator/string/IsPort.ts#L11
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
feat: IsPort decorator should accept number value #826 - GitHub
So we would check if the received value is a number and convert it to a string and then pass it to the...
Read more >feat: IsPort decorator should accept number value -
I was trying to... class Config { @IsPort() port: number; } const c = new Config(); c.port = 3000; console.log(validateSync(c)) // error ...
Read more >What is Feature Engineering — Importance, Tools and ...
This blog post will explain how feature scaling works and why it's important as well as some tips for getting started with feature...
Read more >Apple Watch SE: The ultimate combination of design, function ...
Apple Watch SE packs the essential features of Apple Watch into a modern design customers love at an affordable price. Design and Performance....
Read more >Xbox Design Lab | Xbox
Design your own next-gen Xbox Wireless Controller in the Xbox Design Lab. Choose from a combination of colors, patterns, textured triggers, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I added such a custom decorator to my project:
I am down for discussion, but still afraid of multiple types. How about accepting only numbers then, does that makes more sense? I am not totally firm on not allowing multiple types, but I would like to see some more feedback on this, before going down this path.