Skip to content

fix(date): Correct error message handling in chained date validations#2

Merged
ersinkoc merged 1 commit into
mainfrom
fix-date-validator-error-message
Oct 25, 2025
Merged

fix(date): Correct error message handling in chained date validations#2
ersinkoc merged 1 commit into
mainfrom
fix-date-validator-error-message

Conversation

@ersinkoc

Copy link
Copy Markdown
Owner

Previously, when chaining date validation methods like min() and max(), the error message from the last validation would overwrite any previous messages. This resulted in incorrect error messages when an earlier validation in the chain failed.

This commit refactors the VldDate validator to associate each validation check with its own error message. The checks array in DateValidatorConfig now stores objects containing both the validation function and its corresponding message, ensuring that the correct error is thrown when a check fails.

A new test case has been added to verify that chained error messages are handled correctly.

Previously, when chaining date validation methods like `min()` and `max()`, the error message from the last validation would overwrite any previous messages. This resulted in incorrect error messages when an earlier validation in the chain failed.

This commit refactors the `VldDate` validator to associate each validation check with its own error message. The `checks` array in `DateValidatorConfig` now stores objects containing both the validation function and its corresponding message, ensuring that the correct error is thrown when a check fails.

A new test case has been added to verify that chained error messages are handled correctly.
@ersinkoc ersinkoc merged commit 18ea79d into main Oct 25, 2025
0 of 3 checks passed
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @ersinkoc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to resolve a bug in date validation where chaining multiple validation methods would result in only the last validation's error message being displayed. The proposed solution involves refactoring the VldDate validator to ensure each validation step correctly reports its specific error message. Additionally, the PR updates the Jest configuration to support ESM and adjusts several development dependency versions.

Highlights

  • Corrected Chained Date Validation Errors: The primary goal of this PR is to fix an issue where chained date validation methods (e.g., min(), max()) would overwrite previous error messages, leading to incorrect error reporting.
  • Refactored VldDate Validator: The VldDate validator has been refactored to associate each validation check with its own specific error message, ensuring that the correct error is thrown when a check fails.
  • New Test Case for Chained Errors: A new test case has been added to verify the proper handling of error messages in chained date validations.
  • Development Environment Updates: Includes updates to Jest configuration for ESM support and adjustments to development dependencies.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request aims to correct error message handling in chained date validations. However, the provided code changes only include updates to configuration files (jest.config.js) and dependency management files (package.json, package-lock.json), without the actual implementation of the bug fix in the VldDate validator or the new test cases. My review is therefore limited to the files presented. The main concerns are a version downgrade of the package itself in package-lock.json and a downgrade of the ts-jest dependency, which are both unusual and potentially problematic.

Comment thread package-lock.json
Comment on lines +3 to +9
"version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@oxog/vld",
"version": "1.1.1",
"version": "1.1.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The package version has been downgraded from 1.1.1 to 1.1.0 in two places within this block. For a bug fix, the version should be incremented according to semantic versioning principles (e.g., to 1.1.2). Downgrading can cause significant issues for consumers of this package. Please correct the versioning.

Comment thread package.json
"rollup": "^4.46.2",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "^29.4.5",
"ts-jest": "^29.4.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The ts-jest dependency is being downgraded from version ^29.4.5 to ^29.4.1. Downgrading dependencies can re-introduce old bugs or miss out on important security fixes and improvements. If this downgrade is intentional to work around a specific issue with the newer version, please add a comment to explain the reasoning. Otherwise, it would be best to revert to the latest version.

Suggested change
"ts-jest": "^29.4.1",
"ts-jest": "^29.4.5",

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