Skip to content

Commit

Permalink
chore: another one
Browse files Browse the repository at this point in the history
  • Loading branch information
nick134-bit committed Nov 8, 2024
1 parent 8db45af commit ebd1ec9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion util/amountInputValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const amountInputValidation = (input: string): string => {
replace(/^(?:\.|0{2,}\.)/u, '0.').
// Eliminating multiple leading zeros before the numbers between 1-9
replace(/^0+(?=[0-9])/u, '').
replace(/\.?0+$/u, '')
// Remove excess zeros after decimal point
replace(/\.(\d+?)0{2,}$/u, '.$10')
// Ensuring multiple decimal points can't be used
return input.indexOf('.') !== amount.lastIndexOf('.') ?
amount.slice(0, amount.indexOf('.') + 1) + amount.slice(amount.indexOf('.')).replaceAll('.', '')
Expand Down

0 comments on commit ebd1ec9

Please sign in to comment.