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

Allow 1 and 0 for boolean values in Value#asBoolean #517

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

ymo-sci
Copy link
Contributor

@ymo-sci ymo-sci commented Mar 21, 2024

in https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#boolean 1 and 0 are also allowed as valid boolean values. In Some places we read from XML and have StructuredNode.queryValue("VALUE_WITH_0_OR_1").asBoolean(false) which should also return true if the value is 1

BREAKING: Value#coerce(Boolean.class, true) now return true as expected and no longer false if the value is empty

  • fixes: SE-13483

in https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#boolean 1 and 0 are also allowed as valid boolean values.
In Some places we read from XML and have StructuredNode.queryValue("VALUE_WITH_0_OR_1").asBoolean(false) which should also return true if the value is 1

- fixes: SE-13483
@ymo-sci ymo-sci added 🐛 Bugfix Contains only a small fix for an existing bug 💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code labels Mar 21, 2024
Therefore add missing tests for coerce with default values and always trim to be less strict

BREAKING: Value#coerce(Boolean.class, true) now return true as expected and no longer false if the value is empty

- fixes: SE-13483
src/main/java/sirius/kernel/commons/Value.java Outdated Show resolved Hide resolved
src/main/java/sirius/kernel/commons/Value.java Outdated Show resolved Hide resolved
src/main/java/sirius/kernel/commons/Value.java Outdated Show resolved Hide resolved
@ymo-sci ymo-sci requested a review from idlira March 21, 2024 12:50
@ymo-sci ymo-sci merged commit 559d1d6 into develop Mar 22, 2024
3 checks passed
@ymo-sci ymo-sci deleted the feature/ymo/SE-13483-boolean-01 branch March 22, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🐛 Bugfix Contains only a small fix for an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants