We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1a617ef commit 2d71292Copy full SHA for 2d71292
1 file changed
src/utils/validation.ts
@@ -0,0 +1,18 @@
1
+export function isValidAddress(address: string): boolean {
2
+ return /^S[PM][0-9A-Z]{38,39}$/.test(address)
3
+}
4
+
5
+export function isPositiveNumber(value: string): boolean {
6
+ const n = parseFloat(value)
7
+ return !isNaN(n) && n > 0
8
9
10
+export function isValidLockBlocks(blocks: number): boolean {
11
+ return [0, 525, 1050, 2100].includes(blocks)
12
13
14
+export function validateStakeInput(amount: string, balance: number): string | null {
15
+ if (!isPositiveNumber(amount)) return 'Enter a valid amount'
16
+ if (parseFloat(amount) > balance) return 'Insufficient balance'
17
+ return null
18
0 commit comments