Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third party adapters #462

Merged
merged 40 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
18b58b1
chore: first pass
crutchcorn Sep 9, 2023
f7effb8
chore: onto something I think
crutchcorn Sep 9, 2023
b3d8dc2
chore: closer but no cigar
crutchcorn Sep 9, 2023
5647643
chore: infer validator
crutchcorn Sep 9, 2023
8b69f2a
chore: infer zod
crutchcorn Sep 9, 2023
a352f29
feat: add validation transformer logic
crutchcorn Sep 9, 2023
0b6339f
chore: fix typings for react adapter
crutchcorn Sep 9, 2023
f6c6ce7
chore: fix issue with `this` not being defined properly
crutchcorn Sep 10, 2023
8130e8b
chore: mostly update FieldInfo types from Vue
crutchcorn Sep 10, 2023
e917c8c
chore: work on fixing type inferencing
crutchcorn Sep 11, 2023
2f6ce80
fix: make ValidatorType optional
crutchcorn Sep 11, 2023
5536f97
chore: make TName restriction easier to grok
crutchcorn Sep 11, 2023
3d4ddb1
chore: fix React types
crutchcorn Sep 11, 2023
1a1521e
chore: fix Vue types
crutchcorn Sep 11, 2023
b2c4b41
chore: fix typing issues
crutchcorn Sep 11, 2023
5a4db83
chore: fix various linting items
crutchcorn Sep 11, 2023
402d0e9
chore: fix ESlint and validation logic
crutchcorn Sep 11, 2023
a3e3a6a
Merge branch 'main' into third-party-adapters
crutchcorn Oct 9, 2023
9c3fb94
chore: fix inferencing from formdata
crutchcorn Oct 17, 2023
47737ec
chore: fix form inferencing
crutchcorn Oct 17, 2023
b51e6bd
chore: fix React TS types to match form validator logic
crutchcorn Oct 17, 2023
065c567
chore: fix Vue types
crutchcorn Oct 17, 2023
7833b9d
chore: migrate zod validation to dedicated package
crutchcorn Oct 17, 2023
426edfa
chore: add first integration test for zod adapter
crutchcorn Oct 17, 2023
dded09d
chore: enable non-validator types to be passed to validator
crutchcorn Oct 17, 2023
f023dcd
feat: add yup 1.x adapter
crutchcorn Oct 17, 2023
f6e843e
chore: add functionality and tests for form-wide validators
crutchcorn Oct 17, 2023
2a8ec56
chore: fix typings of async validation types
crutchcorn Oct 17, 2023
037dee6
fix: async validation should now run as-expected more often
crutchcorn Oct 17, 2023
c772997
chore: add async tests for Yup validator
crutchcorn Oct 17, 2023
e347406
Merge branch 'main' into third-party-adapters
crutchcorn Oct 17, 2023
347ef36
chore: rename packages to match naming schema better
crutchcorn Oct 17, 2023
04c0d4a
chore: add Zod examples for React and Vue
crutchcorn Oct 17, 2023
f143254
chore: add React and Vue Yup support
crutchcorn Oct 17, 2023
b7452ea
chore: fix formatting
crutchcorn Oct 17, 2023
a5ce5e3
chore: fix CI types
crutchcorn Oct 17, 2023
7b0e6b0
chore: initial work to drastically improve docs
crutchcorn Oct 18, 2023
d21e745
Merge branch 'main' into third-party-adapters
crutchcorn Oct 18, 2023
fa84809
docs: improve docs for validation
crutchcorn Oct 18, 2023
96aaa8f
docs: add adapter validation docs
crutchcorn Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
"label": "Guides",
"children": [
{
"label": "Important Defaults",
"to": "guides/important-defaults"
"label": "Basic Concepts",
"to": "guides/basic-concepts"
},
{
"label": "Form Validation",
"to": "guides/validation"
}
]
},
Expand Down Expand Up @@ -89,6 +93,14 @@
{
"label": "Simple",
"to": "framework/react/examples/simple"
},
{
"label": "Yup",
"to": "framework/react/examples/yup"
},
{
"label": "Zod",
"to": "framework/react/examples/zod"
}
]
}
Expand Down Expand Up @@ -133,6 +145,14 @@
{
"label": "Simple",
"to": "framework/vue/examples/simple"
},
{
"label": "Yup",
"to": "framework/vue/examples/yup"
},
{
"label": "Zod",
"to": "framework/vue/examples/zod"
}
]
}
Expand Down
38 changes: 29 additions & 9 deletions docs/guides/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ title: Basic Concepts and Terminology

# Basic Concepts and Terminology

> Some of these docs may be inaccurate due to an API shift in `0.11.0`. If you're interested in helping us fix these issues, please [join our Discord](https://tlinz.com/discord) and reach out in the `#form` channel.

This page introduces the basic concepts and terminology used in the @tanstack/react-form library. Familiarizing yourself with these concepts will help you better understand and work with the library.
This page introduces the basic concepts and terminology used in the `@tanstack/react-form` library. Familiarizing yourself with these concepts will help you better understand and work with the library.

## Form Factory

Expand Down Expand Up @@ -86,7 +84,7 @@ Example:

## Validation

@tanstack/react-form provides both synchronous and asynchronous validation out of the box. Validation functions can be passed to the form.Field component using the validate and validateAsync props.
`@tanstack/react-form` provides both synchronous and asynchronous validation out of the box. Validation functions can be passed to the form.Field component using the validate and validateAsync props.

Example:

Expand All @@ -111,9 +109,34 @@ Example:
/>
```

## Validation Adapters

In addition to hand-rolled validation options, we also provide adapters like `@tanstack/zod-form-adapter` and `@tanstack/yup-form-adapter` to enable usage with common schema validation tools like [Yup](https://github.com/jquense/yup) and [Zod](https://zod.dev/).

Example:

```tsx
<form.Field
name="firstName"
onChange={z
.string()
.min(3, "First name must be at least 3 characters")}
onChangeAsyncDebounceMs={500}
onChangeAsync={z.string().refine(
async (value) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return !value.includes("error");
},
{
message: "No 'error' allowed in first name",
},
)}
/>
```

## Reactivity

@tanstack/react-form offers various ways to subscribe to form and field state changes, such as the form.useStore hook, the form.Subscribe component, and the form.useField hook. These methods allow you to optimize your form's rendering performance by only updating components when necessary.
`@tanstack/react-form` offers various ways to subscribe to form and field state changes, such as the `form.useStore` hook, the `form.Subscribe` component, and the `form.useField` hook. These methods allow you to optimize your form's rendering performance by only updating components when necessary.

Example:

Expand Down Expand Up @@ -240,8 +263,5 @@ Example:
/>
```

These are the basic concepts and terminology used in the @tanstack/react-form library. Understanding these concepts will help you work more effectively with the library and create complex forms with ease.
These are the basic concepts and terminology used in the `@tanstack/react-form` library. Understanding these concepts will help you work more effectively with the library and create complex forms with ease.

```

```
21 changes: 0 additions & 21 deletions docs/guides/important-defaults.md

This file was deleted.

Loading