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

Issue with parameters that take 0 #7

Open
danielskowronski opened this issue Dec 26, 2023 · 0 comments
Open

Issue with parameters that take 0 #7

danielskowronski opened this issue Dec 26, 2023 · 0 comments

Comments

@danielskowronski
Copy link

In many places, but particularly painful with setting clock mode, you can't set a parameter to 0 after it has been set to non-zero. This is because values are incorrectly validated as having value using simple casting to boolean. The issue is that 0 casts to false, yet it's a correct value for those parameters.

For example, for the aforementioned clock mode:
https://github.com/jfroehlich/node-p1x3lramen/blob/main/source/service.js#L193C21-L193C21 we have req.query.mode which will yield false for 0 and thus not passing mode parameter to https://github.com/jfroehlich/node-p1x3lramen/blob/main/source/devices/pixoo.js#L99

From my experience in old, low-level JS it seems like ! isNaN(parseInt(req.query.mode, 10)) could be enough. Maybe there are some smarter validators in NodeJS.

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

1 participant