Skip to content

Commit

Permalink
Update index.mdx (QwikDev#3650)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamatoyogi authored Apr 4, 2023
1 parent 3a39ac6 commit a244ff1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/docs/src/routes/docs/(qwikcity)/action/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contributors:
- cunzaizhuyi
- forresst
- keuller
- hamatoyogi
---

# `routeAction$()`
Expand Down Expand Up @@ -147,7 +148,7 @@ export const useAddUser = routeAction$((user) => {
});
```

Fortunately, actions have first class support for [Zod](https://zod.dev/), a TypeScript-first data validation library. To use Zod, simply pass the Zod schema as the second argument to the `action$()` function.
Fortunately, actions have first class support for [Zod](https://zod.dev/), a TypeScript-first data validation library. To use Zod, simply pass the Zod schema as the second argument to the `routeAction$()` function.

```tsx title="src/routes/index.tsx"
import { routeAction$, zod$, z } from '@builder.io/qwik-city';
Expand All @@ -167,7 +168,7 @@ export const useAddUser = routeAction$(
);
```

When submitting data to an action, the data is validated against the Zod schema. If the data is invalid, the action will put the validation error in the `action.fail` property.
When submitting data to a `routeAction()`, the data is validated against the Zod schema. If the data is invalid, the action will put the validation error in the `routeAction.fail` property.

```tsx
import { component$ } from '@builder.io/qwik';
Expand Down

0 comments on commit a244ff1

Please sign in to comment.