File tree Expand file tree Collapse file tree
docs/framework/react/guides
examples/react/standard-schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -446,6 +446,7 @@ TanStack Form natively supports all libraries following the [Standard Schema spe
446446- [Zod](https://zod.dev/)
447447- [Valibot](https://valibot.dev/)
448448- [ArkType](https://arktype.io/)
449+ - [Effect/Schema](https://effect.website/docs/schema/standard-schema/)
449450
450451_Note:_ make sure to use the latest version of the schema libraries as older versions might not support Standard Schema yet.
451452
Original file line number Diff line number Diff line change 1111 "dependencies" : {
1212 "@tanstack/react-form" : " ^1.2.4" ,
1313 "arktype" : " ^2.1.15" ,
14+ "effect" : " ^3.13.8" ,
1415 "react" : " ^19.0.0" ,
1516 "react-dom" : " ^19.0.0" ,
1617 "valibot" : " ^1.0.0" ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import * as React from 'react'
44import { createRoot } from 'react-dom/client'
55import * as v from 'valibot'
66import { z } from 'zod'
7+ import { Schema as S } from 'effect'
78import type { AnyFieldApi } from '@tanstack/react-form'
89
910function FieldInfo ( { field } : { field : AnyFieldApi } ) {
@@ -42,6 +43,23 @@ const ArkTypeSchema = type({
4243 lastName : 'string >= 3' ,
4344} )
4445
46+ const EffectSchema = S . standardSchemaV1 (
47+ S . Struct ( {
48+ firstName : S . String . pipe (
49+ S . minLength ( 3 ) ,
50+ S . annotations ( {
51+ message : ( ) => '[Effect/Schema] You must have a length of at least 3' ,
52+ } ) ,
53+ ) ,
54+ lastName : S . String . pipe (
55+ S . minLength ( 3 ) ,
56+ S . annotations ( {
57+ message : ( ) => '[Effect/Schema] You must have a length of at least 3' ,
58+ } ) ,
59+ ) ,
60+ } ) ,
61+ )
62+
4563export default function App ( ) {
4664 const form = useForm ( {
4765 defaultValues : {
@@ -53,6 +71,7 @@ export default function App() {
5371 onChange : ZodSchema ,
5472 // onChange: ValibotSchema,
5573 // onChange: ArkTypeSchema,
74+ // onChange: EffectSchema,
5675 } ,
5776 onSubmit : async ( { value } ) => {
5877 // Do something with form data
You can’t perform that action at this time.
0 commit comments