Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query still runs when Zod parse fails #15

Open
Psionyc opened this issue Aug 3, 2024 · 0 comments
Open

Query still runs when Zod parse fails #15

Psionyc opened this issue Aug 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Psionyc
Copy link

Psionyc commented Aug 3, 2024

Describe the bug
I had a user schema with the following

import { RecordSchema } from "cirql"
import * as cirql from "cirql"
import { z } from "zod"
import db from "../modules/DatabaseModule"

export const UserSchema = RecordSchema.extend({
    name: z.string(),
    email: z.string().email(),
    username: z.string(),
    password: z.string(),
    phoneNumber: z.string(),
    verified: z.boolean().default(false),
})

export type User = z.infer<typeof UserSchema>;

On my request validation the phoneNumber wasn't compulsory but the zod schema made the phoneNumber compulsory...
When I tried to run the request I got the error below but to my surprise the data was present in the database

error: Query 1 failed to parse
- @0.phoneNumber: Required
 code: "parse_failure"

Expected behavior
I expected the query not to run if the zod validation failed so the database wouldn't have any values

Environment:

  • OS: Windows
  • Version: 1.0.1
  • Bun Version : 1.0.2
@Psionyc Psionyc added the bug Something isn't working label Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant