Skip to content

Commit e523dde

Browse files
titouancreachakoenigdudeofawesome
authored
chore: update to effet 3.10 (react-hook-form#720)
* chore: update to effet 3.10 * fix: remove package-lock and regenerate bun * fix: remove @effect/schema from the peerDependencies. * chore(effect-ts): adjusts microbundle build * docs: update effect README --------- Co-authored-by: André König <andre.koenig@openformation.io> Co-authored-by: Louis Orleans <louis@orleans.io>
1 parent 3ab415e commit e523dde

File tree

9 files changed

+22
-22
lines changed

9 files changed

+22
-22
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,13 +653,13 @@ const App = () => {
653653

654654
A powerful TypeScript framework that provides a fully-fledged functional effect system with a rich standard library.
655655

656-
[![npm](https://img.shields.io/bundlephobia/minzip/@effect/schema?style=for-the-badge)](https://bundlephobia.com/result?p=effect)
656+
[![npm](https://img.shields.io/bundlephobia/minzip/effect?style=for-the-badge)](https://bundlephobia.com/result?p=effect)
657657

658658
```typescript jsx
659659
import React from 'react';
660660
import { useForm } from 'react-hook-form';
661661
import { effectTsResolver } from '@hookform/resolvers/effect-ts';
662-
import { Schema } from '@effect/schema';
662+
import { Schema } from 'effect';
663663

664664
const schema = Schema.Struct({
665665
username: Schema.String.pipe(

bun.lockb

-395 Bytes
Binary file not shown.

effect-ts/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"license": "MIT",
1313
"peerDependencies": {
1414
"@hookform/resolvers": "^2.0.0",
15-
"@effect/schema": "^0.66.14",
16-
"effect": "^3.1.2",
15+
"effect": "^3.10.3",
1716
"react-hook-form": "^7.0.0"
1817
}
1918
}

effect-ts/src/__tests__/Form-native-validation.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Schema } from '@effect/schema';
21
import { render, screen } from '@testing-library/react';
32
import user from '@testing-library/user-event';
3+
import { Schema } from 'effect';
44
import React from 'react';
55
import { useForm } from 'react-hook-form';
66
import { effectTsResolver } from '..';
@@ -10,10 +10,10 @@ const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
1010

1111
const schema = Schema.Struct({
1212
username: Schema.String.pipe(
13-
Schema.nonEmpty({ message: () => USERNAME_REQUIRED_MESSAGE }),
13+
Schema.nonEmptyString({ message: () => USERNAME_REQUIRED_MESSAGE }),
1414
),
1515
password: Schema.String.pipe(
16-
Schema.nonEmpty({ message: () => PASSWORD_REQUIRED_MESSAGE }),
16+
Schema.nonEmptyString({ message: () => PASSWORD_REQUIRED_MESSAGE }),
1717
),
1818
});
1919

effect-ts/src/__tests__/Form.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Schema } from '@effect/schema';
21
import { render, screen } from '@testing-library/react';
32
import user from '@testing-library/user-event';
3+
import { Schema } from 'effect';
44
import React from 'react';
55
import { useForm } from 'react-hook-form';
66
import { effectTsResolver } from '..';
@@ -10,10 +10,10 @@ const PASSWORD_REQUIRED_MESSAGE = 'password field is required';
1010

1111
const schema = Schema.Struct({
1212
username: Schema.String.pipe(
13-
Schema.nonEmpty({ message: () => USERNAME_REQUIRED_MESSAGE }),
13+
Schema.nonEmptyString({ message: () => USERNAME_REQUIRED_MESSAGE }),
1414
),
1515
password: Schema.String.pipe(
16-
Schema.nonEmpty({ message: () => PASSWORD_REQUIRED_MESSAGE }),
16+
Schema.nonEmptyString({ message: () => PASSWORD_REQUIRED_MESSAGE }),
1717
),
1818
});
1919

effect-ts/src/__tests__/__fixtures__/data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Schema } from '@effect/schema';
1+
import { Schema } from 'effect';
22
import { Field, InternalFieldName } from 'react-hook-form';
33

44
export const schema = Schema.Struct({
55
username: Schema.String.pipe(
6-
Schema.nonEmpty({ message: () => 'A username is required' }),
6+
Schema.nonEmptyString({ message: () => 'A username is required' }),
77
),
88
password: Schema.String.pipe(
99
Schema.pattern(new RegExp('.*[A-Z].*'), {

effect-ts/src/effect-ts.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { formatIssue } from '@effect/schema/ArrayFormatter';
2-
import { decodeUnknown } from '@effect/schema/ParseResult';
31
import { toNestErrors, validateFieldsNatively } from '@hookform/resolvers';
4-
import * as Effect from 'effect/Effect';
2+
import { Effect } from 'effect';
3+
4+
import { ArrayFormatter, decodeUnknown } from 'effect/ParseResult';
55
import type { FieldErrors } from 'react-hook-form';
66
import type { Resolver } from './types';
77

@@ -12,7 +12,9 @@ export const effectTsResolver: Resolver =
1212
schema,
1313
config,
1414
)(values).pipe(
15-
Effect.catchAll((parseIssue) => Effect.flip(formatIssue(parseIssue))),
15+
Effect.catchAll((parseIssue) =>
16+
Effect.flip(ArrayFormatter.formatIssue(parseIssue)),
17+
),
1618
Effect.mapError((issues) => {
1719
const errors = issues.reduce((acc, current) => {
1820
const key = current.path.join('.');

effect-ts/src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Schema } from '@effect/schema';
2-
import { ParseOptions } from '@effect/schema/AST';
1+
import { Schema } from 'effect';
2+
import { ParseOptions } from 'effect/SchemaAST';
33
import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
44

55
export type Resolver = <A extends FieldValues, I, TContext>(

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
"build:arktype": "microbundle --cwd arktype --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
209209
"build:valibot": "microbundle --cwd valibot --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
210210
"build:typeschema": "microbundle --cwd typeschema --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@typeschema/main=main",
211-
"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",
211+
"build:effect-ts": "microbundle --cwd effect-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,effect=Effect,effect/SchemaAST=EffectSchemaAST,effect/ParseResult=EffectParseResult",
212212
"build:vine": "microbundle --cwd vine --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm,@vinejs/vine=vine",
213213
"build:fluentvalidation-ts": "microbundle --cwd fluentvalidation-ts --globals @hookform/resolvers=hookformResolvers,react-hook-form=ReactHookForm",
214214
"postbuild": "node ./config/node-13-exports.js && check-export-map",
@@ -256,7 +256,6 @@
256256
},
257257
"homepage": "https://react-hook-form.com",
258258
"devDependencies": {
259-
"@effect/schema": "^0.68.17",
260259
"@sinclair/typebox": "^0.32.34",
261260
"@testing-library/dom": "^10.3.1",
262261
"@testing-library/jest-dom": "^6.4.6",
@@ -277,7 +276,7 @@
277276
"class-validator": "^0.14.1",
278277
"computed-types": "^1.11.2",
279278
"cross-env": "^7.0.3",
280-
"effect": "^3.4.7",
279+
"effect": "^3.10.3",
281280
"fluentvalidation-ts": "^3.2.0",
282281
"fp-ts": "^2.16.7",
283282
"io-ts": "^2.2.21",
@@ -308,4 +307,4 @@
308307
"peerDependencies": {
309308
"react-hook-form": "^7.0.0"
310309
}
311-
}
310+
}

0 commit comments

Comments
 (0)