Skip to content

Refactor - Module#1

Merged
Feresaul merged 11 commits intomainfrom
refactor
Jul 18, 2025
Merged

Refactor - Module#1
Feresaul merged 11 commits intomainfrom
refactor

Conversation

@Feresaul
Copy link
Copy Markdown
Owner

No description provided.

Feresaul added 10 commits July 14, 2025 20:02
…anced type handling and validation flexibility
… 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.
@Feresaul Feresaul requested a review from Copilot July 18, 2025 00:50
Copy link
Copy Markdown

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 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 baseForgeType system
  • Migrates from synchronous/async dual APIs to async-only with unified forge() method
  • Renames blueprint to object and 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 || [])
});
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

[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));

Copilot uses AI. Check for mistakes.
@Feresaul Feresaul merged commit cbd5516 into main Jul 18, 2025
1 check passed
@Feresaul Feresaul deleted the refactor branch July 18, 2025 01:03
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.

2 participants