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

feat(conform-zod): strip empty value #224

Merged
merged 4 commits into from
Jul 17, 2023
Merged

feat(conform-zod): strip empty value #224

merged 4 commits into from
Jul 17, 2023

Conversation

edmundhung
Copy link
Owner

Fix #196.

This adds an extra option on parse to strip all empty value. This is an opt-in feature for now and very likely the default on v0.8.

// Instead of this:
const schema = z.object({
  text: z.string().min(1, 'Email is required');
});

const submission = parse(formData, { schema });

// Do this:
const schema = z.object({
  email: z.string({ required_error: 'Email is required'),
});

const submission = parse(formData, { schema, stripEmptyValue: true });

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 17, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: dab5448
Status: ✅  Deploy successful!
Preview URL: https://fa086dbd.conform.pages.dev
Branch Preview URL: https://strip-empty-value.conform.pages.dev

View logs

@edmundhung edmundhung merged commit 2e5617f into next Jul 17, 2023
2 checks passed
@edmundhung edmundhung deleted the strip-empty-value branch July 17, 2023 19:19
nicholaschiang added a commit to nicholaschiang/dolce that referenced this pull request Jul 25, 2023
This patch refactors the sign up page to create a new profile settings
page that allows users to preview what their consumer reviews will look
like and update their username, name, email, and password accordingly.

Eventually, I should also add a profile picture upload input.

This patch takes advantage of Conform's new `skipEmptyValues` option to
optionally accept the `password` field in this settings page.

Ref: https://github.com/edmundhung/conform/releases/tag/v0.7.4
Ref: edmundhung/conform#224
Ref: edmundhung/conform#196
nicholaschiang added a commit to nicholaschiang/dolce that referenced this pull request Jul 25, 2023
This patch refactors the sign up page to create a new profile settings
page that allows users to preview what their consumer reviews will look
like and update their username, name, email, and password accordingly.

Eventually, I should also add a profile picture upload input.

This patch takes advantage of Conform's new `skipEmptyValues` option to
optionally accept the `password` field in this settings page.

Ref: https://github.com/edmundhung/conform/releases/tag/v0.7.4
Ref: edmundhung/conform#224
Ref: edmundhung/conform#196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant