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

add effect-form-adapter #718

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@
"label": "Valibot",
"to": "framework/react/examples/valibot"
},
{
"label": "Effect",
"to": "framework/react/examples/effect"
},
{
"label": "UI Libraries",
"to": "framework/react/examples/ui-libraries"
Expand Down Expand Up @@ -302,6 +306,10 @@
{
"label": "Valibot",
"to": "framework/vue/examples/valibot"
},
{
"label": "Effect",
"to": "framework/vue/examples/effect"
}
]
},
Expand All @@ -327,6 +335,10 @@
{
"label": "Valibot",
"to": "framework/angular/examples/valibot"
},
{
"label": "Effect",
"to": "framework/angular/examples/effect"
}
]
},
Expand All @@ -352,6 +364,10 @@
{
"label": "Valibot",
"to": "framework/solid/examples/valibot"
},
{
"label": "Effect",
"to": "framework/solid/examples/effect"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/framework/angular/guides/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class AppComponent {

## Validation Adapters

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

Example:

Expand Down
4 changes: 3 additions & 1 deletion docs/framework/angular/guides/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ This will debounce every async call with a 500ms delay. You can even override th

## Adapter-Based Validation (Zod, Yup, Valibot)

While functions provide more flexibility and customization over your validation, they can be a bit verbose. To help solve this, there are libraries like [Valibot](https://valibot.dev/), [Yup](https://github.com/jquense/yup), and [Zod](https://zod.dev/) that provide schema-based validation to make shorthand and type-strict validation substantially easier.
While functions provide more flexibility and customization over your validation, they can be a bit verbose. To help solve this, there are libraries like [Valibot](https://valibot.dev/), [Yup](https://github.com/jquense/yup), [Zod](https://zod.dev/), and [Effect Schema](https://effect.website) that provide schema-based validation to make shorthand and type-strict validation substantially easier.

Luckily, we support all of these libraries through official adapters:

Expand All @@ -394,6 +394,8 @@ $ npm install @tanstack/zod-form-adapter zod
$ npm install @tanstack/yup-form-adapter yup
# or
$ npm install @tanstack/valibot-form-adapter valibot
# or
$ npm install @tanstack/effect-form-adapter effect @effect/schema
```

Once done, we can add the adapter to the `validator` property on the form or field:
Expand Down
2 changes: 1 addition & 1 deletion docs/framework/react/guides/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Example:

## Validation Adapters

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

Example:

Expand Down
4 changes: 3 additions & 1 deletion docs/framework/react/guides/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ This will debounce every async call with a 500ms delay. You can even override th

## Adapter-Based Validation (Zod, Yup, Valibot)

While functions provide more flexibility and customization over your validation, they can be a bit verbose. To help solve this, there are libraries like [Valibot](https://valibot.dev/), [Yup](https://github.com/jquense/yup), and [Zod](https://zod.dev/) that provide schema-based validation to make shorthand and type-strict validation substantially easier.
While functions provide more flexibility and customization over your validation, they can be a bit verbose. To help solve this, there are libraries like [Valibot](https://valibot.dev/), [Yup](https://github.com/jquense/yup), [Zod](https://zod.dev/), and [Effect Schema](https://effect.website) that provide schema-based validation to make shorthand and type-strict validation substantially easier.

Luckily, we support all of these libraries through official adapters:

Expand All @@ -322,6 +322,8 @@ $ npm install @tanstack/zod-form-adapter zod
$ npm install @tanstack/yup-form-adapter yup
# or
$ npm install @tanstack/valibot-form-adapter valibot
# or
$ npm install @tanstack/effect-form-adapter effect @effect/schema
```

Once done, we can add the adapter to the `validator` property on the form or field:
Expand Down
6 changes: 4 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ $ pnpm add @tanstack/lit-form

> Depending on your environment, you might need to add polyfills. If you want to support older browsers, you need to transpile the library from `node_modules` yourselves.

In addition, we support Zod, Yup, and Valibot as validators through official validator packages:
In addition, we support Zod, Yup, Valibot, and Effect Schema as validators through official validator packages:

```bash
$ npm i @tanstack/zod-form-adapter zod
# or
$ npm i @tanstack/yup-form-adapter yup
# or
$ npm i @tanstack/valibot-form-adapter valibot
```
# or
$ npm i @tanstack/effect-form-adapter effect @effect/schema
```
2 changes: 1 addition & 1 deletion docs/reference/formApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ An object representing the options for a form.
- ```tsx
validatorAdapter?: TFormValidator
```
- A validator adapter to support usage of extra validation types (IE: Zod, Yup, or Valibot usage)
- A validator adapter to support usage of extra validation types (IE: Zod, Yup, Valibot or Effect usage)

- ```tsx
validators?: FormValidators<TFormData, TFormValidator>
Expand Down
16 changes: 16 additions & 0 deletions examples/angular/effect/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions examples/angular/effect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
27 changes: 27 additions & 0 deletions examples/angular/effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Simple

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.1.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
78 changes: 78 additions & 0 deletions examples/angular/effect/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"simple": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/simple",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "simple:build:production"
},
"development": {
"buildTarget": "simple:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "simple:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"assets": ["src/favicon.ico", "src/assets"],
"scripts": []
}
}
}
}
}
}
35 changes: 35 additions & 0 deletions examples/angular/effect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@tanstack/form-example-angular-effect",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "ng build",
"ng": "ng",
"start": "ng cache clean && ng serve",
"test": "ng test",
"watch": "ng build --watch --configuration development"
},
"dependencies": {
"@angular/animations": "^17.3.0",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
"@angular/core": "^17.3.0",
"@angular/forms": "^17.3.0",
"@angular/platform-browser": "^17.3.0",
"@angular/platform-browser-dynamic": "^17.3.0",
"@angular/router": "^17.3.0",
"@effect/schema": "^0.67.18",
"@tanstack/angular-form": "^0.20.3",
"@tanstack/effect-form-adapter": "workspace:^",
"effect": "^3.2.8",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.3.0",
"@angular/cli": "^17.3.0",
"@angular/compiler-cli": "^17.3.0",
"typescript": "5.4.2"
}
}
Loading
Loading