diff --git a/README.md b/README.md index 07a0362f..b0273b5f 100644 --- a/README.md +++ b/README.md @@ -653,13 +653,13 @@ const App = () => { A powerful TypeScript framework that provides a fully-fledged functional effect system with a rich standard library. -[![npm](https://img.shields.io/bundlephobia/minzip/@effect/schema?style=for-the-badge)](https://bundlephobia.com/result?p=effect) +[![npm](https://img.shields.io/bundlephobia/minzip/effect?style=for-the-badge)](https://bundlephobia.com/result?p=effect) ```typescript jsx import React from 'react'; import { useForm } from 'react-hook-form'; import { effectTsResolver } from '@hookform/resolvers/effect-ts'; -import { Schema } from '@effect/schema'; +import { Schema } from 'effect'; const schema = Schema.Struct({ username: Schema.String.pipe( diff --git a/bun.lockb b/bun.lockb index ec887df0..6dddebc4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/effect-ts/package.json b/effect-ts/package.json index b29cc929..0c357c6d 100644 --- a/effect-ts/package.json +++ b/effect-ts/package.json @@ -12,8 +12,7 @@ "license": "MIT", "peerDependencies": { "@hookform/resolvers": "^2.0.0", - "@effect/schema": "^0.66.14", - "effect": "^3.1.2", + "effect": "^3.10.3", "react-hook-form": "^7.0.0" } } diff --git a/effect-ts/src/__tests__/Form-native-validation.tsx b/effect-ts/src/__tests__/Form-native-validation.tsx index 2f7ef231..4ea73afc 100644 --- a/effect-ts/src/__tests__/Form-native-validation.tsx +++ b/effect-ts/src/__tests__/Form-native-validation.tsx @@ -1,6 +1,6 @@ -import { Schema } from '@effect/schema'; import { render, screen } from '@testing-library/react'; import user from '@testing-library/user-event'; +import { Schema } from 'effect'; import React from 'react'; import { useForm } from 'react-hook-form'; import { effectTsResolver } from '..'; @@ -10,10 +10,10 @@ const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; const schema = Schema.Struct({ username: Schema.String.pipe( - Schema.nonEmpty({ message: () => USERNAME_REQUIRED_MESSAGE }), + Schema.nonEmptyString({ message: () => USERNAME_REQUIRED_MESSAGE }), ), password: Schema.String.pipe( - Schema.nonEmpty({ message: () => PASSWORD_REQUIRED_MESSAGE }), + Schema.nonEmptyString({ message: () => PASSWORD_REQUIRED_MESSAGE }), ), }); diff --git a/effect-ts/src/__tests__/Form.tsx b/effect-ts/src/__tests__/Form.tsx index ee6a84a5..d3f6fd2f 100644 --- a/effect-ts/src/__tests__/Form.tsx +++ b/effect-ts/src/__tests__/Form.tsx @@ -1,6 +1,6 @@ -import { Schema } from '@effect/schema'; import { render, screen } from '@testing-library/react'; import user from '@testing-library/user-event'; +import { Schema } from 'effect'; import React from 'react'; import { useForm } from 'react-hook-form'; import { effectTsResolver } from '..'; @@ -10,10 +10,10 @@ const PASSWORD_REQUIRED_MESSAGE = 'password field is required'; const schema = Schema.Struct({ username: Schema.String.pipe( - Schema.nonEmpty({ message: () => USERNAME_REQUIRED_MESSAGE }), + Schema.nonEmptyString({ message: () => USERNAME_REQUIRED_MESSAGE }), ), password: Schema.String.pipe( - Schema.nonEmpty({ message: () => PASSWORD_REQUIRED_MESSAGE }), + Schema.nonEmptyString({ message: () => PASSWORD_REQUIRED_MESSAGE }), ), }); diff --git a/effect-ts/src/__tests__/__fixtures__/data.ts b/effect-ts/src/__tests__/__fixtures__/data.ts index a74af9e6..90368e47 100644 --- a/effect-ts/src/__tests__/__fixtures__/data.ts +++ b/effect-ts/src/__tests__/__fixtures__/data.ts @@ -1,9 +1,9 @@ -import { Schema } from '@effect/schema'; +import { Schema } from 'effect'; import { Field, InternalFieldName } from 'react-hook-form'; export const schema = Schema.Struct({ username: Schema.String.pipe( - Schema.nonEmpty({ message: () => 'A username is required' }), + Schema.nonEmptyString({ message: () => 'A username is required' }), ), password: Schema.String.pipe( Schema.pattern(new RegExp('.*[A-Z].*'), { diff --git a/effect-ts/src/effect-ts.ts b/effect-ts/src/effect-ts.ts index 0dc8f818..f3b8ba70 100644 --- a/effect-ts/src/effect-ts.ts +++ b/effect-ts/src/effect-ts.ts @@ -1,7 +1,7 @@ -import { formatIssue } from '@effect/schema/ArrayFormatter'; -import { decodeUnknown } from '@effect/schema/ParseResult'; import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers'; -import * as Effect from 'effect/Effect'; +import { Effect } from 'effect'; + +import { ArrayFormatter, decodeUnknown } from 'effect/ParseResult'; import type { FieldErrors } from 'react-hook-form'; import type { Resolver } from './types'; @@ -12,7 +12,9 @@ export const effectTsResolver: Resolver = schema, config, )(values).pipe( - Effect.catchAll((parseIssue) => Effect.flip(formatIssue(parseIssue))), + Effect.catchAll((parseIssue) => + Effect.flip(ArrayFormatter.formatIssue(parseIssue)), + ), Effect.mapError((issues) => { const errors = issues.reduce((acc, current) => { const key = current.path.join('.'); diff --git a/effect-ts/src/types.ts b/effect-ts/src/types.ts index 25b6d367..4be50137 100644 --- a/effect-ts/src/types.ts +++ b/effect-ts/src/types.ts @@ -1,5 +1,5 @@ -import { Schema } from '@effect/schema'; -import { ParseOptions } from '@effect/schema/AST'; +import { Schema } from 'effect'; +import { ParseOptions } from 'effect/SchemaAST'; import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form'; export type Resolver = ( diff --git a/package.json b/package.json index 660e4cab..1dc5734f 100644 --- a/package.json +++ b/package.json @@ -208,7 +208,7 @@ "build:arktype": "microbundle --cwd arktype --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm", "build:valibot": "microbundle --cwd valibot --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm", "build:typeschema": "microbundle --cwd typeschema --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@typeschema/main=main", - "build:effect-ts": "microbundle --cwd effect-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@effect/schema=EffectSchema,@effect/schema/AST=EffectSchemaAST,@effect/schema/ArrayFormatter=EffectSchemaArrayFormatter,@effect/schema/ParseResult=EffectSchemaArrayFormatter,effect/Effect=Effect", + "build:effect-ts": "microbundle --cwd effect-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,effect=Effect,effect/SchemaAST=EffectSchemaAST,effect/ParseResult=EffectParseResult", "build:vine": "microbundle --cwd vine --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@vinejs/vine=vine", "build:fluentvalidation-ts": "microbundle --cwd fluentvalidation-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm", "postbuild": "node ./config/node-13-exports.js && check-export-map", @@ -256,7 +256,6 @@ }, "homepage": "https://react-hook-form.com", "devDependencies": { - "@effect/schema": "^0.68.17", "@sinclair/typebox": "^0.32.34", "@testing-library/dom": "^10.3.1", "@testing-library/jest-dom": "^6.4.6", @@ -277,7 +276,7 @@ "class-validator": "^0.14.1", "computed-types": "^1.11.2", "cross-env": "^7.0.3", - "effect": "^3.4.7", + "effect": "^3.10.3", "fluentvalidation-ts": "^3.2.0", "fp-ts": "^2.16.7", "io-ts": "^2.2.21", @@ -308,4 +307,4 @@ "peerDependencies": { "react-hook-form": "^7.0.0" } -} \ No newline at end of file +}