Skip to content

Commit

Permalink
chore: update valibot dependency to v1 (#972)
Browse files Browse the repository at this point in the history
* chore: update valibot dependency to v1

* refactor:remove unnecessary code from valibot adapter

---------

Co-authored-by: Leonardo Montini <[email protected]>
  • Loading branch information
fabian-hiller and Balastrong authored Oct 16, 2024
1 parent 611f2a6 commit c8bcc60
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 175 deletions.
2 changes: 1 addition & 1 deletion examples/angular/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@tanstack/valibot-form-adapter": "^0.33.0",
"rxjs": "^7.8.1",
"tslib": "^2.7.0",
"valibot": "^0.42.1",
"valibot": "1.0.0-beta.0",
"zone.js": "^0.15.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@tanstack/valibot-form-adapter": "^0.33.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"valibot": "^0.42.1"
"valibot": "1.0.0-beta.0"
},
"devDependencies": {
"@types/react": "^18.3.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/solid/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@tanstack/solid-form": "^0.33.0",
"@tanstack/valibot-form-adapter": "^0.33.0",
"solid-js": "^1.9.2",
"valibot": "^0.42.1"
"valibot": "1.0.0-beta.0"
},
"devDependencies": {
"typescript": "5.4.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@tanstack/valibot-form-adapter": "^0.33.0",
"@tanstack/vue-form": "^0.33.0",
"valibot": "^0.42.1",
"valibot": "1.0.0-beta.0",
"vue": "^3.3.4"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/valibot-form-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
},
"devDependencies": {
"@tanstack/react-form": "workspace:*",
"valibot": "^0.42.1"
"valibot": "1.0.0-beta.0"
},
"peerDependencies": {
"valibot": ">=0.33.0 <1"
"valibot": "^1.0.0"
}
}
19 changes: 4 additions & 15 deletions packages/valibot-form-adapter/src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { getDotPath, safeParse, safeParseAsync } from 'valibot'
import { setBy } from '@tanstack/form-core'
import { safeParse, safeParseAsync } from 'valibot'
import type {
ValidationError,
Validator,
ValidatorAdapterParams,
} from '@tanstack/form-core'
import type {
BaseIssue,
GenericIssue,
GenericSchema,
GenericSchemaAsync,
ValiError,
} from 'valibot'
import type { GenericIssue, GenericSchema, GenericSchemaAsync } from 'valibot'

type Params = ValidatorAdapterParams<GenericIssue>
type TransformFn = NonNullable<Params['transformErrors']>
Expand Down Expand Up @@ -68,19 +61,15 @@ export const valibotValidator =
return {
validate({ value, validationSource }, fn) {
if (fn.async) return
const result = safeParse(fn, value, {
abortPipeEarly: false,
})
const result = safeParse(fn, value)
if (result.success) return

const transformer = getTransformStrategy(validationSource)

return transformer(result.issues)
},
async validateAsync({ value, validationSource }, fn) {
const result = await safeParseAsync(fn, value, {
abortPipeEarly: false,
})
const result = await safeParseAsync(fn, value)
if (result.success) return

const transformer = getTransformStrategy(validationSource)
Expand Down
308 changes: 154 additions & 154 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

0 comments on commit c8bcc60

Please sign in to comment.