-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix: Accept object or string for date string validation error message #4067
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
base: main
Are you sure you want to change the base?
Fix: Accept object or string for date string validation error message #4067
Conversation
WalkthroughThis pull request introduces additional test cases and updates associated with the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client Code
participant Z as ZodString.date Method
participant E as errorUtil.errToObj
participant A as _addCheck
C->>Z: Invoke date(customErrorMessage)
Z->>E: Convert customErrorMessage to error object
E-->>Z: Return error object
Z->>A: Add validation check with error object
A-->>Z: Validation check added
Possibly related issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🔇 Additional comments (4)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for guileless-rolypoly-866f8a ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deployment failed with the following error:
|
Overview
This PR corrects an inconsistency present in date string validation. Currently, in the documentation there is this example code in the Strings section:
z.string().date({ message: "Invalid date string!" });
However, this does not work as the
string().date
function currently only accepts a string argument for a custom error message (unlike all other ZodString functions). My changes allow a string or a string within an object as an argument.Benefits
Result
Summary by CodeRabbit