Skip to content

feat: replace zod type with standard schema#5570

Closed
R5dan wants to merge 3 commits intobetter-auth:canaryfrom
R5dan:standard-schema
Closed

feat: replace zod type with standard schema#5570
R5dan wants to merge 3 commits intobetter-auth:canaryfrom
R5dan:standard-schema

Conversation

@R5dan
Copy link
Copy Markdown

@R5dan R5dan commented Oct 25, 2025

Adds standard schema to better auth


Summary by cubic

Introduce a vendor-agnostic Standard Schema v1 for field validation. This removes the Zod dependency in DB validators and standardizes validate calls across core and better-auth.

  • Refactors

    • Added StandardSchemaV1 interface (core/types/standard-schema.ts).
    • Replaced ZodType with StandardSchemaV1 for DBFieldAttributeConfig.validator input/output.
    • Updated better-auth parseInputData to call schema["~standard"].validate(...).
  • Migration

    • Update any custom DB field validators to implement Standard Schema v1 or wrap existing Zod schemas.

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 25, 2025

@R5dan is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

@R5dan R5dan mentioned this pull request Oct 25, 2025
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@R5dan
Copy link
Copy Markdown
Author

R5dan commented Oct 25, 2025

@cubic-dev-ai Can you find any other places where there is a ZodType being used that should be replaced by StandardSchema. Ignore any situations where zod is being used as the validation library to provide the validation, but flag any situations where the user is being forced to use zod

@R5dan
Copy link
Copy Markdown
Author

R5dan commented Oct 25, 2025

@himself65 @Bekacru @ping-maxwell Do any of you have any feedback on this? Can it be reviewed and merged

@ping-maxwell
Copy link
Copy Markdown
Member

hmm I think this is a fine change.
Also I'm pretty sure we've already exported our own standard schema from better-call or somewhere already, so let's use that instead of having another standard schema code in the codebase

@R5dan
Copy link
Copy Markdown
Author

R5dan commented Oct 26, 2025

Also I'm pretty sure we've already exported our own standard schema from better-call or somewhere already, so let's use that instead of having another standard schema code in the codebase

@ping-maxwell yes, better-call or better-fetch export standard schema, however personally I think this should have its own type as they are not "standard schema packages" but instead they both have there own functionality, so it feels weird to me to use them for it, however it is upto you

@himself65 himself65 changed the title standard schema feat: replace zod type with standard schema Oct 27, 2025
@himself65 himself65 force-pushed the standard-schema branch 3 times, most recently from 6e663b8 to c6b6fb3 Compare October 27, 2025 23:31
@R5dan
Copy link
Copy Markdown
Author

R5dan commented Oct 28, 2025

@himself65 can I ask what happened here? Did you rewrite to make the code cleaner?

@better-auth better-auth locked as resolved and limited conversation to collaborators Apr 1, 2026
@bytaesu bytaesu added the locked Locked conversations after being closed for 7 days label Apr 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked Locked conversations after being closed for 7 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants