Closed licanhua closed 2 years ago
Ditto for int()
to be used with value
, min
, and max
for number fields.
Another way of thinking about this, if the parsing is too much of a challenge: Could you adjust the API of these fields that require boolean, integers, etc. to allow for equivalents as well. So, 3 == "3"
or true == 'true'
or even true == 1
. Making the API more liberal in what it accepts (with guardrails of course) would make for a more robust solution overall and eliminate the need for this sort of value coercion in a template to begin with.
Is this a regression? I'm not sure if this is a new feature request or a bug since this PR seems to address it: https://github.com/microsoft/AdaptiveCards/pull/4351
@JeanRoca Given the dates, I’m guessing it’s a regression. Not sure if it is extended to int()
, but if it isn’t it should be.
I think this might be just Designer issue. let me try that. There will be a lot more issues filed if this doesn't work.
I verify that it does work in code.
I've updated the feature request with a proposed solution.
This also happens when trying to set image height and width using the data payload. You can only see the image change size when you hit preview mode. Is this expected behavior?
Card JSON
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "Image test:",
"wrap": true
},
{
"type": "Image",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"width": "${imageSize}",
"height": "${imageSize}"
}
]
}
Data JSON
{
"imageSize": "100px"
}
Problem Statement
$ is not a valid usage in JSON, so it has problem to convert the template data to bool directly.
Proposed solution
Data binding works as expected as requested in this feature request. To see the correct usage, see 4350. Designer needs to be updated so that a serialization doesn't happen before template expansion because templates are stripped off if the expected type are not string.
Alternatives or Workarounds
No response