Skip to content

Integer property with default 0 is incorrectly nullable #43

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

Closed
dktapps opened this issue Oct 6, 2021 · 3 comments
Closed

Integer property with default 0 is incorrectly nullable #43

dktapps opened this issue Oct 6, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@dktapps
Copy link
Contributor

dktapps commented Oct 6, 2021

Describe the bug
A property with a default value is not typically nullable, but if its default is 0, it's marked as nullable anyway.

Expected behavior
Integer properties with 0 as the default value shouldn't be nullable.

Schema

				"global-limit": {
					"type": "integer",
					"minimum": 0,
					"description": "Global soft memory limit (MB). When reached, low-memory triggers will fire to try and free memory.",
					"default": 1
				},

Version:
Which version of the library do you use?
dev-master as of about 1h ago.

Additional context
My bet is that there's some weak comparison == somewhere that's responsible for this bug.

@wol-soft wol-soft added the bug Something isn't working label Oct 7, 2021
@wol-soft
Copy link
Owner

wol-soft commented Oct 7, 2021

Yeah, I've spotted the problem. It's caused by the string "0" evaluating to false. I'll patch the master branch with a test covering the case.

@wol-soft
Copy link
Owner

wol-soft commented Oct 7, 2021

I've tagged a new bugfix version (0.21.1) which includes the fixes for the issues you opened. Thanks for the reports again!

I hope the library is useful for you, would be glad to hear how it's going 😃

@dktapps
Copy link
Contributor Author

dktapps commented Oct 7, 2021

I've actually been searching for something like this for a long time, I had the same idea several years ago wrt. codegen but never found the time or motivation to do it.

I'm very happy with it so far, it's greatly improved validation of various configs used in PocketMine-MP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants