๐Ÿšซย ๋ฌธ์ œ์ƒํ™ฉ

<aside> ๐Ÿ’ก ํŠน์ • ์กฐ๊ฑด์— ๋”ฐ๋ผ Send to ํ•„๋“œ๊ฐ€ ๋ Œ๋”๋ง ๋˜๋Š” ํŽ˜์ด์ง€๊ฐ€ ์žˆ๋‹ค. react-hook-form์„ ์ด์šฉํ•ด to์™€ amount field๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ , yup์„ ํ†ตํ•ด์„œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ์ง„ํ–‰ํ•˜์˜€๋‹ค. ๊ทธ๋Ÿฐ๋ฐ Send to๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์€ ํŽ˜์ด์ง€์—์„œ Valide๊ฐ€ ์›ํ•˜๋Š”๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์˜€๋‹ค.

</aside>

Untitled

Untitled

scemeaHelper

โ˜Ž๏ธŽ ํ•ด๊ฒฐ์„ ์œ„ํ•œ ๋…ธ๋ ฅ1

ํ˜น์‹œ to๊ฐ€ required๋ผ์„œ ๋ฐœ์ƒํ•œ ๊ฒƒ์€ ์•„๋‹Œ๊ฐ€ ์‹ถ์–ด to๋ฅผ ์œ„ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๋กœ์ง์„ ๋”ฐ๋กœ ๋งŒ๋“ค์—ˆ๋‹ค.

const determineIfToFieldIsRequired = (
    value: string,
    userDataAccount: string | undefined,
  ): boolean => {
    return isToFieldRequired
      ? ethers.utils.isAddress(value) && value !== userDataAccount
      : true;
  };

  const isToFieldValidate = determineIfToFieldIsRequired(
    toFieldValue!,
    userData?.account,
  );

ํ•˜์ง€๋งŒ ๊ทธ๋Ÿผ์—๋„ isValid๋Š” ๋ชจ๋‘๊ฐ€ ์œ ํšจํ•œ ์ƒํ™ฉ์—์„œ false์กฐ๊ฑด์ธ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

๋ฌธ์ œ์  ์ฒดํฌ

Untitled

amount๊ฐ€ ํ•œ๋ฐ•์ž ๋Šฆ๊ฒŒ ์ „๋‹ฌ๋˜๊ณ  ์žˆ๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.