Skip to content

Conversation

samchon
Copy link
Owner

@samchon samchon commented Jul 6, 2025

This pull request introduces improvements to validation handling, refactors error reporting, and updates test cases to align with the new validation logic. The most important changes include enhancements to the IValidation namespace, removal of unused code, and the addition of new test cases for validation scenarios.

Enhancements to validation handling:

  • Updated the IValidation.IError.value field to support undefined values for more precise error reporting in cases of missing required properties or null/undefined validation scenarios. This improves the flexibility and accuracy of validation feedback. (src/structures/IValidation.ts, [1] [2]
  • Added examples of validation errors where required properties are omitted or malformed, providing better documentation for real-world AI function calling scenarios. (src/structures/IValidation.ts, src/structures/IValidation.tsR142-R147)

Refactoring:

  • Removed the description field from error mapping in OpenApiValidator, simplifying the error reporting logic. (src/utils/OpenApiValidator.ts, src/utils/OpenApiValidator.tsL58)

Updates to test cases:

  • Added a new test case in discriminate.ts to validate schemas using OpenApiValidator and typia, including validation of discriminated union types (ICat and IAnt). (test/src/executable/discriminate.ts, test/src/executable/discriminate.tsR1-R33)
  • Removed an outdated test case in validate.ts that used OpenApiTypeChecker and ClaudeSchemaComposer, as it is no longer relevant to the updated validation logic. (test/src/executable/validate.ts, test/src/executable/validate.tsL1-L245)

@samchon samchon requested a review from Copilot July 6, 2025 20:51
@samchon samchon self-assigned this Jul 6, 2025
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 6, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refines the validation error API to better support undefined values, simplifies the OpenAPI validator logic, and updates test coverage by removing outdated tests and adding a discriminated-union validation scenario.

  • Support undefined in IValidation.IError.value and improve its documentation.
  • Remove the description field from error reports in OpenApiValidator.
  • Delete an obsolete test file and introduce a new test for discriminated-union validation.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/structures/IValidation.ts Changed value type to unknown and enhanced doc comments with examples.
src/utils/OpenApiValidator.ts Removed description from reported errors to simplify the validation output.
test/src/executable/validate.ts Deleted outdated test for OpenApiTypeChecker and ClaudeSchemaComposer.
test/src/executable/discriminate.ts Added a new test case for discriminated-union validation using typia.
Comments suppressed due to low confidence (4)

src/utils/OpenApiValidator.ts:57

  • Removing the description field from reported errors may break consumers relying on human-readable messages; consider updating the interface or documentation to reflect this change and migrate consumers accordingly.
          value: error.value,

src/structures/IValidation.ts:178

  • Changing value from any to unknown tightens the error API and may cause consumer code to require additional type assertions or checks; consider documenting upgrade steps or providing helper functions to ease migration.
    value: unknown;

test/src/executable/discriminate.ts:14

  • [nitpick] This test logs validation results but lacks assertions; consider replacing console.log with explicit assertions (e.g., expect statements) to automatically verify expected failures in CI.
console.log(result);

@samchon samchon merged commit 2ebe83b into master Jul 6, 2025
4 checks passed
@samchon samchon deleted the feat/validate branch July 6, 2025 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant