Skip to content

Commit

Permalink
fix(Swap): handle when schema params are undefined (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao authored Jun 28, 2023
1 parent 509960f commit c1e15ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/form/schemas/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ const swapSchema = (params: { [SWAP_INPUT_AMOUNT_FIELD]: SwapValidationParams })
[SWAP_INPUT_TOKEN_FIELD]: yup.string().required('amm.select_token'),
[SWAP_OUTPUT_TOKEN_FIELD]: yup.string().required('amm.select_token'),
[SWAP_INPUT_AMOUNT_FIELD]: yup.string().when([SWAP_INPUT_TOKEN_FIELD, SWAP_OUTPUT_TOKEN_FIELD], {
is: (input: string, output: string) => input && output,
is: (input: string, output: string) => {
// only validates when params are declared
const { maxAmount, minAmount } = params[SWAP_INPUT_AMOUNT_FIELD];

return input && output && minAmount && maxAmount;
},
then: (schema) =>
schema
.requiredAmount(undefined, 'amm.enter_token_amount')
Expand Down

2 comments on commit c1e15ac

@vercel
Copy link

@vercel vercel bot commented on c1e15ac Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c1e15ac Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.