Skip to content

Commit

Permalink
🛠️ Fixed validation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdin committed Oct 23, 2024
1 parent 86ea5d2 commit 94a4403
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "commonjs",
"name": "@chord-ts/rpc",
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.16",
"author": "Din Dmitriy @dmdin",
"description": "💎 Cutting edge transport framework vanishing borders between frontend and backend",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/validators/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface ValidateAdapter<T, K> {
validate(validator?: T, value?: K): {success: boolean, error: Error}
export interface ValidateAdapter {
validate(validator, value): {success: boolean, error: Error}
}
10 changes: 5 additions & 5 deletions src/validators/zod.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ValidateAdapter } from "./types";
import type {ZodType} from 'zod'

export const ZodAdapter: ValidateAdapter<ZodType, any> = {
validate(validator: ZodType, value: any) {
if (!validator) return value
export const ZodAdapter = {
validate(validator: unknown, value: unknown) {
if (!validator) return {success: true, error: null}
// @ts-ignore
return validator.safeParse(value)
},
}
} satisfies ValidateAdapter

0 comments on commit 94a4403

Please sign in to comment.