-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add convert to bool if string or number receive for boolean value #467
Add convert to bool if string or number receive for boolean value #467
Conversation
}).getEndpoint("foo"); | ||
|
||
let typedValues = NativeSerializer.nativeToTypedValues( | ||
[true, "true", "TRUE", 1, false, "false", "falseString", 0, 5], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
}).getEndpoint("foo"); | ||
|
||
let typedValues = NativeSerializer.nativeToTypedValues( | ||
[true, "true", "TRUE", 1, false, "false", "falseString", 0, 5], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"falseString"
can be "foobar"
- test is thus more explicit about arbitrary strings.
@@ -610,4 +610,59 @@ describe("test native serializer", () => { | |||
variadic: false, | |||
}); | |||
}); | |||
|
|||
it.only("should accept a mixed of values for boolen type", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slipped "only".
@@ -296,7 +296,8 @@ export namespace NativeSerializer { | |||
return new AddressValue(convertNativeToAddress(native, errorContext)); | |||
} | |||
if (type instanceof BooleanType) { | |||
return new BooleanValue(native); | |||
const boolValue = native.toString().toLowerCase() === "true" || native.toString() === "1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be more appropriate in the "isTrue" evaluation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value from BooleanValue is expected to be bool, here we accept any type that's why we thought it's better to be here
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@multiversx/sdk-core", | |||
"version": "13.2.2", | |||
"version": "13.2.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's bump the minor version, so that developers take this update intentionally (not as a hotfix) - v13.3.0
.
Add convert to bool before creating the boolean value to cover the scenarios where boolean value is passed as string or number.
This is a follow up at this issue #258