Skip to content

docs(validation): api docs & minor fixes #3713

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

Merged
merged 10 commits into from
Mar 12, 2025
Merged

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Mar 11, 2025

Summary

Changes

Please provide a summary of what's being changed

This PR adds docstrings to all the types/functions/parameters/errors for the upcoming Validation utility and enables Typedoc for the package.

While documenting the code I noticed a few inconsistencies or redundant code paths, which are refactored in this PR along with their respective tests. I also added the build command and removed the private marker from the package.json file, since we're gonna start publishing in the next release.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3712


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Mar 11, 2025
@dreamorosi dreamorosi linked an issue Mar 11, 2025 that may be closed by this pull request
1 task
@pull-request-size pull-request-size bot added the size/XL PRs between 500-999 LOC, often PRs that grown with feedback label Mar 11, 2025
@boring-cyborg boring-cyborg bot added the dependencies Changes that touch dependencies, e.g. Dependabot, etc. label Mar 11, 2025
@pull-request-size pull-request-size bot added size/XXL PRs with 1K+ LOC, largely documentation related and removed size/XL PRs between 500-999 LOC, often PRs that grown with feedback labels Mar 12, 2025
@dreamorosi dreamorosi requested review from am29d and Copilot March 12, 2025 10:55
@dreamorosi dreamorosi marked this pull request as ready for review March 12, 2025 10:55
Copy link

@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 enhances the Validation utility by adding comprehensive documentation, refactoring error handling, updating middleware/decorator logic, and aligning tests with these changes.

  • Added detailed jsdoc comments and API docs in the README
  • Refactored error handling and validation logic for consistency
  • Updated tests and type definitions to support upcoming publishing

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/validation/README.md Expanded API docs and added a new "Features" section for better usability
packages/validation/src/utils.ts Added documentation for error cause extraction
packages/validation/src/errors.ts Introduced jsdoc comments and restructured error classes for clarity
packages/validation/tests/unit/middleware.test.ts Updated middleware tests and renamed imports for consistency
packages/validation/src/decorator.ts Added detailed jsdoc comments and refined error handling in the decorator
packages/validation/src/types.ts Updated types for validation parameters and external references
packages/validation/src/middleware.ts Replaced the earlier middleware with a polished validator function and improved error messages
packages/validation/src/validate.ts Enhanced schema compilation error handling and updated externalRefs processing
vitest.config.ts Adjusted file exclusion patterns for improved test coverage
packages/validation/tests/unit/decorator.test.ts Updated tests to reflect the new decorator behavior and naming
packages/validation/tests/unit/validate.test.ts Modified tests for custom formats and error types during schema compilation
README.md Updated badges and added usage instructions for the Validation utility
packages/validation/src/index.ts & tests/unit/index.test.ts Removed re‑exports to match the new package organization
Comments suppressed due to low confidence (3)

packages/validation/src/decorator.ts:170

  • For consistency with the middleware and test expectations, consider updating the error message to 'Inbound schema validation failed'.
throw new SchemaValidationError('Inbound validation failed', {

packages/validation/src/validate.ts:132

  • Ensure that the use of addSchema correctly handles both single schema objects and arrays of schemas, as expected by Ajv.
ajvInstance.addSchema(externalRefs);

packages/validation/src/index.ts:1

  • Confirm that the removal of exports from this file is intentional and that any necessary documentation or package structure updates have been made.
/* exports removed */

Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

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

Looks good, just need to clarify accidental comment.

@dreamorosi dreamorosi requested a review from am29d March 12, 2025 11:22
@dreamorosi dreamorosi merged commit a0795fc into main Mar 12, 2025
41 checks passed
@dreamorosi dreamorosi deleted the chore/validation_api_docs branch March 12, 2025 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Changes that touch dependencies, e.g. Dependabot, etc. size/XXL PRs with 1K+ LOC, largely documentation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: add API Docs & README for Validation utility
2 participants