-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(widget): Fixes decimal input with no leading zeros, wallet cancel…
… on send (#2354) * Fixes decimal input with no leading zeros, wallet cancel on send
- Loading branch information
1 parent
198dc48
commit 8c9f382
Showing
2 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
/** | ||
* This regex matches a string that either: | ||
* 1. consists only of one or more '0' characters | ||
* 2. consists of a single '0' followed by a '.' and zero or more '0' characters | ||
* 3. consists solely of a '.' followed by one or more '0' characters | ||
*/ | ||
|
||
export const isOnlyZeroes = (input: string): boolean => { | ||
return /^(0+(\.0*)?|\.\d+)$/.test(input.trim()) | ||
const regex = /^(0+|0?\.0+)$/ | ||
|
||
return regex.test(input.trim()) | ||
} |