dify icon indicating copy to clipboard operation
dify copied to clipboard

Number input starting with 0 don't work.

Open AndyMik90 opened this issue 1 year ago • 2 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.7.3

Cloud or Self Hosted

Cloud, Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Create input field with number, start the number with 0 and any other number, the input registered will be without the 0.

CleanShot 2024-09-07 at 22 21 27@2x CleanShot 2024-09-07 at 22 23 07@2x

I'm aware that we can use string to make it work, but wanted to report the problem.

✔️ Expected Behavior

Certain numbers can start with 0, like Zip-code, this should be able to be included?

❌ Actual Behavior

0 is removed from the number.

AndyMik90 avatar Sep 07 '24 20:09 AndyMik90

Dify currently does not support leading zeros in number inputs. When a number input starts with a zero, the leading zero is stripped away. This behavior is due to how numerical strings are converted to integers or floats in the backend, which inherently removes leading zeros.

For cases like Zip-codes, where leading zeros are significant, using a string input type is the recommended workaround. This ensures that the leading zeros are preserved.

If you need further assistance or have more questions, feel free to ask!

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Sep 07 '24 20:09 dosubot[bot]

The "Number" type variable will be converted to an integer or a float object in Python, so it cannot start with 0.

laipz8200 avatar Sep 08 '24 18:09 laipz8200