form updates

This commit is contained in:
fmtabbara
2021-09-11 00:32:54 +01:00
parent b77025bfd5
commit 74e34567b4
2 changed files with 6 additions and 5 deletions
@@ -6,6 +6,6 @@ export const validationSchema = Yup.object().shape({
amount: Yup.string()
.required()
.test('valid-amount', 'A valid amount is required', (amount) => {
return validateAmount(amount || '0', '1')
return validateAmount(amount || '0', '0')
}),
})
+5 -4
View File
@@ -20,15 +20,16 @@ export const validateAmount = async (
minimum: string
): Promise<boolean> => {
// tests basic coin value requirements, like no more than 6 decimal places, value lower than total supply, etc
if (!basicRawCoinValueValidation(amount)) {
return false
}
try {
const minorValueStr: Coin = await invoke('major_to_minor', {
amount,
})
if (!basicRawCoinValueValidation(minorValueStr.amount)) {
return false
}
const minorValue = parseInt(minorValueStr.amount)
return minorValue >= parseInt(minimum)
@@ -44,7 +45,7 @@ export const basicRawCoinValueValidation = (rawAmount: string): boolean => {
if (!Number(rawAmount)) {
return false
}
debugger
const amountFloat = parseFloat(rawAmount)
// it cannot have more than 6 decimal places