feat: add UiInputAmount and decimals validation #592
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Closes: #583
This PR adds new
UiInputAmount
that can be used to input numeric amounts, but without drawbacks of using number input for it:1e-7
).0.000000000000001
and triggering re-render, for example by going to contact picker and back it would be turned to exponential form.UiInputAmount
value has consistent type (always string), whereUiInputNumber
could have eitherstring
(when input is empty) ornumber
.This PR also adds decimals validation so we can validate the form (SendToken and StakeToken).
How to test
Note: Currently if you enter error state (for example too many decimals) and open picker and back dirty flag gets cleared so it won't display the error on UI, but it's true for all inputs at the moment, we have issue for that: #573
Screenshots
Before
Screen.Recording.2024-08-06.at.16.30.14.mov
After
Screen.Recording.2024-08-06.at.16.30.50.mov