Skip to content

Commit

Permalink
Merge pull request #9 from hamsurang/docs/clearErrors
Browse files Browse the repository at this point in the history
Docs: claearErrors.mdx
  • Loading branch information
chaaerim authored Jan 29, 2025
2 parents b9abc71 + 41522ef commit 169cde0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/content/docs/useform/clearerrors.mdx
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
---
title: clearErrors
description: Clear form errors
description: ํผ ์—๋Ÿฌ ์ œ๊ฑฐ
sidebar: apiLinks
---

## \</> `clearErrors:` <TypeText>(name?: string | string[]) => void</TypeText>

This function can manually clear errors in the form.
์ด ํ•จ์ˆ˜๋Š” ํผ์˜ ์—๋Ÿฌ๋ฅผ ์ง์ ‘ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

### Props

---

| Type | Description | Example |
| ------------------------------ | ----------------------- | --------------------------------------- |
| <TypeText>undefined</TypeText> | Remove all errors. | `clearErrors()` |
| <TypeText>string</TypeText> | Remove single error. | `clearErrors("yourDetails.firstName")` |
| <TypeText>string[]</TypeText> | Remove multiple errors. | `clearErrors(["yourDetails.lastName"])` |
| Type | Description | Example |
| ------------------------------ | ----------------- | --------------------------------------- |
| <TypeText>undefined</TypeText> | ๋ชจ๋“  ์—๋Ÿฌ ์ œ๊ฑฐ. | `clearErrors()` |
| <TypeText>string</TypeText> | ํ•˜๋‚˜์˜ ์—๋Ÿฌ ์ œ๊ฑฐ. | `clearErrors("yourDetails.firstName")` |
| <TypeText>string[]</TypeText> | ์—ฌ๋Ÿฌ ์—๋Ÿฌ ์ œ๊ฑฐ. | `clearErrors(["yourDetails.lastName"])` |

- `undefined`: reset all errors
- `string`: reset the error on a single field or by key name.
- `undefined`: ๋ชจ๋“  ์—๋Ÿฌ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.
- `string`: ํ•˜๋‚˜์˜ ํ•„๋“œ ๋˜๋Š” ํ‚ค ์ด๋ฆ„์œผ๋กœ ์—๋Ÿฌ๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.

```javascript
register("test.firstName", { required: true })
register("test.lastName", { required: true })
clearErrors("test") // will clear both errors from test.firstName and test.lastName
clearErrors("test.firstName") // for clear single input error
clearErrors("test") // test.firstName ๋ฐ test.lastName์˜ ๋ชจ๋“  ์—๋Ÿฌ๋ฅผ ์ œ๊ฑฐ
clearErrors("test.firstName") // ํ•˜๋‚˜์˜ ์ž…๋ ฅ ์—๋Ÿฌ ์ œ๊ฑฐ
```

- `string[]`: reset errors on the given fields
- `string[]`: ์ฃผ์–ด์ง„ ํ•„๋“œ์˜ ์˜ค๋ฅ˜๋ฅผ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.

<Admonition type="important" title="Rules">
<Admonition type="important" title="๊ทœ์น™">

- This will not affect the validation rules attached to each inputs.
- This method doesn't affect validation rules or `isValid` formState.
- ์ด ๋ฉ”์†Œ๋“œ๋Š” ๊ฐ ์ž…๋ ฅ ํ•„๋“œ์— ์—ฐ๊ฒฐ๋œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๊ทœ์น™์—๋Š” ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
- ์ด ๋ฉ”์†Œ๋“œ๋Š” ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ๊ทœ์น™์ด๋‚˜ `isValid` formState์—๋Š” ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

</Admonition>

Expand Down

0 comments on commit 169cde0

Please sign in to comment.