Conversation
…anced type handling and validation flexibility
…g validations; remove legacy proposal.ts
… and related types into a new types.ts file; update number and string methods to accept optional config parameter
…eType for improved type handling and validation flexibility
…t/gte for improved clarity and consistency in type handling
… null and true states for improved readability
- Deleted boolean types and validation logic from lib/boolean. - Removed number types and validation logic from lib/number. - Consolidated verification functions into a new types module. - Introduced new array, boolean, number, object, string types with updated validation methods. - Updated index files to reflect new structure and imports. - Enhanced verification logic for async operations and error handling.
…24.0.14, typescript-eslint to 8.37.0, and vitest to 3.2.4
…onsistency; update test cases for various data types (boolean, number, string, object, array) to include async handling, method chaining, and custom checks; add new object tests for nested structures and various combinations; remove deprecated blueprint tests.
There was a problem hiding this comment.
Pull Request Overview
This is a major refactoring that modernizes and simplifies the validation library architecture. The PR replaces the existing type-specific modules with a unified base type system, consolidates API methods, and converts all operations to async-only.
- Replaces complex type-specific implementations with a unified
baseForgeTypesystem - Migrates from synchronous/async dual APIs to async-only with unified
forge()method - Renames
blueprinttoobjectand consolidates all validation methods under consistent patterns
Reviewed Changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/types.ts | New unified type definitions replacing scattered type files |
| lib/baseForgeType.ts | Core implementation providing shared functionality for all validation types |
| lib/forgeTypes/*.ts | New modular type implementations (string, number, boolean, object, array) |
| test/*.test.ts | Updated test suites with async patterns and new API methods |
| lib/index.ts | Updated exports replacing blueprint with object |
Comments suppressed due to low confidence (1)
test/string.test.ts:22
- The test validates a string 'hi' against a minLength(5) constraint, but the test description mentions minLength(6) in the removed code. Consider verifying the test logic matches the intended validation rules.
expect((await schema.forge('hi')).success).toBe(false);
Comment on lines
+71
to
+86
| if (issue.issues) { | ||
| levelIssues = levelIssues.concat( | ||
| issue.issues?.map((subIssue) => ({ | ||
| success: false, | ||
| caller: subIssue.caller, | ||
| errorCode: subIssue.errorCode, | ||
| errorMessage: subIssue.errorMessage, | ||
| path: [key] | ||
| })) ?? [] | ||
| ); | ||
| return; | ||
| } | ||
| levelIssues.push({ | ||
| ...issue, | ||
| path: [key].concat(issue.path || []) | ||
| }); |
There was a problem hiding this comment.
[nitpick] The nested issue mapping logic is complex and could be extracted into a separate utility function for better readability and reusability.
Suggested change
| if (issue.issues) { | |
| levelIssues = levelIssues.concat( | |
| issue.issues?.map((subIssue) => ({ | |
| success: false, | |
| caller: subIssue.caller, | |
| errorCode: subIssue.errorCode, | |
| errorMessage: subIssue.errorMessage, | |
| path: [key] | |
| })) ?? [] | |
| ); | |
| return; | |
| } | |
| levelIssues.push({ | |
| ...issue, | |
| path: [key].concat(issue.path || []) | |
| }); | |
| levelIssues = levelIssues.concat(mapNestedIssues(key, issue)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.