From 0572697dc1b1ea56601dadc27219c9f10e977a17 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 17 Dec 2023 17:40:49 +0200 Subject: [PATCH 1/4] Fix max transfer amount --- packages/playground/src/dashboard/transfer_view.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/playground/src/dashboard/transfer_view.vue b/packages/playground/src/dashboard/transfer_view.vue index 834e741165..e2ffd2afdb 100644 --- a/packages/playground/src/dashboard/transfer_view.vue +++ b/packages/playground/src/dashboard/transfer_view.vue @@ -37,8 +37,8 @@ :rules="[ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), - validators.min('Amount must be greater than 0', 0.00000000001), - validators.max('Insufficient funds', freeBalance), + validators.min('Amount must be greater than 0', 0.001), + validators.max('Insufficient funds', +freeBalance.toFixed(3)), ]" #="{ props }" > @@ -87,8 +87,8 @@ :rules="[ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), - validators.min('Amount must be greater than 0', 0.00000000001), - validators.max('Insufficient funds', freeBalance), + validators.min('Amount must be greater than 0', 0.001), + validators.max('Insufficient funds', +freeBalance.toFixed(3)), ]" #="{ props }" > From 5dcaf1be5330f94c26060c3b6b5379eee1db9ef4 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Sun, 17 Dec 2023 17:56:35 +0200 Subject: [PATCH 2/4] Validate transfer amount using regex --- .../playground/src/dashboard/transfer_view.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/playground/src/dashboard/transfer_view.vue b/packages/playground/src/dashboard/transfer_view.vue index e2ffd2afdb..6d9fe1e23d 100644 --- a/packages/playground/src/dashboard/transfer_view.vue +++ b/packages/playground/src/dashboard/transfer_view.vue @@ -37,8 +37,11 @@ :rules="[ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), - validators.min('Amount must be greater than 0', 0.001), - validators.max('Insufficient funds', +freeBalance.toFixed(3)), + validators.min('Amount must be greater than 0.', 0.001), + validators.max('Insufficient funds.', freeBalance), + validators.pattern('Amount can have 3 decimals only.', { + pattern: /^\d+(\.\d{1,3})?$/, + }), ]" #="{ props }" > @@ -87,8 +90,11 @@ :rules="[ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), - validators.min('Amount must be greater than 0', 0.001), - validators.max('Insufficient funds', +freeBalance.toFixed(3)), + validators.min('Amount must be greater than 0.', 0.001), + validators.max('Insufficient funds.', freeBalance), + validators.pattern('Amount can have 3 decimals only.', { + pattern: /^\d+(\.\d{1,3})?$/, + }), ]" #="{ props }" > From 90f8f9de472785842b0ed3714f5632011d6219e1 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Mon, 18 Dec 2023 12:41:42 +0200 Subject: [PATCH 3/4] Use isDecimal instead of pattern --- packages/playground/src/dashboard/transfer_view.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/playground/src/dashboard/transfer_view.vue b/packages/playground/src/dashboard/transfer_view.vue index 6d9fe1e23d..a80278d214 100644 --- a/packages/playground/src/dashboard/transfer_view.vue +++ b/packages/playground/src/dashboard/transfer_view.vue @@ -39,9 +39,7 @@ validators.isNumeric('Amount should be a number.'), validators.min('Amount must be greater than 0.', 0.001), validators.max('Insufficient funds.', freeBalance), - validators.pattern('Amount can have 3 decimals only.', { - pattern: /^\d+(\.\d{1,3})?$/, - }), + validators.isDecimal('Amount can have 3 decimals only.', { decimal_digits: '0,3' }), ]" #="{ props }" > @@ -92,9 +90,7 @@ validators.isNumeric('Amount should be a number.'), validators.min('Amount must be greater than 0.', 0.001), validators.max('Insufficient funds.', freeBalance), - validators.pattern('Amount can have 3 decimals only.', { - pattern: /^\d+(\.\d{1,3})?$/, - }), + validators.isDecimal('Amount can have 3 decimals only.', { decimal_digits: '0,3' }), ]" #="{ props }" > From 6f971807f9ce341f512d9639ff1746b67ee01199 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Mon, 18 Dec 2023 12:53:21 +0200 Subject: [PATCH 4/4] Rearrage validations --- packages/playground/src/dashboard/transfer_view.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playground/src/dashboard/transfer_view.vue b/packages/playground/src/dashboard/transfer_view.vue index a80278d214..2e153692de 100644 --- a/packages/playground/src/dashboard/transfer_view.vue +++ b/packages/playground/src/dashboard/transfer_view.vue @@ -38,8 +38,8 @@ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), validators.min('Amount must be greater than 0.', 0.001), - validators.max('Insufficient funds.', freeBalance), validators.isDecimal('Amount can have 3 decimals only.', { decimal_digits: '0,3' }), + validators.max('Insufficient funds.', freeBalance), ]" #="{ props }" > @@ -89,8 +89,8 @@ validators.required('Transfer amount is required '), validators.isNumeric('Amount should be a number.'), validators.min('Amount must be greater than 0.', 0.001), - validators.max('Insufficient funds.', freeBalance), validators.isDecimal('Amount can have 3 decimals only.', { decimal_digits: '0,3' }), + validators.max('Insufficient funds.', freeBalance), ]" #="{ props }" >