-
Notifications
You must be signed in to change notification settings - Fork 7k
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: Add URL-type input in booking question field #15481
base: main
Are you sure you want to change the base?
Conversation
@anikdhabal is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
Graphite Automations"Add community label" took an action on this PR • (06/18/24)1 label was added to this PR based on Keith Williams's automation. "Add consumer team as reviewer" took an action on this PR • (06/18/24)1 reviewer was added to this PR based on Keith Williams's automation. |
@@ -120,6 +120,7 @@ function preprocess<T extends z.ZodType>({ | |||
return isValidPhoneNumber(val); | |||
}); | |||
// Tag the message with the input name so that the message can be shown at appropriate place | |||
const urlSchema = z.string().url(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line came in b/w comment on line 122 and related code.
if (bookingField.type === "url") { | ||
// URL schema to validate if the input is a valid URL | ||
if (!urlSchema.safeParse(value).success) { | ||
ctx.addIssue({ | ||
code: z.ZodIssueCode.custom, | ||
message: m("url_validation_error"), | ||
}); | ||
} | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}, |
superRefine
for url
type field in the same way we have done for 'name' type field.
We want to avoid increase this file's size and make all refinements testable.
After that it would make sense to add a simple test for url type field schema validation
url: { | ||
propsType: propsTypes.url, | ||
factory: (props) => { | ||
if (!props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where props could be undefined
?
It feels wrong to return a different element from the same component conditionally. Like if no props are provided return <div>
otherwise <TextWidget>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some feedback
What does this PR do?
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Checklist