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

Fix: Avoid implicit type coercion in validation logic examples #65

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

minseong0324
Copy link

@minseong0324 minseong0324 commented Jan 14, 2025

  • Replaced implicit type coercion (!value) in the validation logic with an explicit comparison using value.trim() === "".
  • Ensures that input containing only whitespace is also treated as invalid.

ref: #21

Copy link

vercel bot commented Jan 14, 2025

@minseong0324 is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@@ -38,7 +38,8 @@ export function Form() {
<div>
<input
{...register("name", {
validate: (value) => (!value ? "이름을 입력해주세요." : ""),
validate: (value) =>
(value.trim() === "" ? "이름을 입력해주세요." : ""),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be good if "Please enter your name." is displayed even when the value is nullish.
How about handling this with a utility function like isEmptyStringOrNil(value)?

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.

2 participants