refactor: update object property checks and improve date validation f…#1111
refactor: update object property checks and improve date validation f…#1111chantouchsek wants to merge 13 commits into
Conversation
3d66c38 to
df297c8
Compare
There was a problem hiding this comment.
Pull request overview
This PR primarily updates dependencies (per linked issue #1110) and includes a few small refactors in utility helpers (object property checks, string operations) plus a minor tweak to error lookup logic.
Changes:
- Bump runtime/dev dependencies (notably eslint/vitest tooling) and refresh
pnpm-lock.yaml. - Refactor string/object utilities (
replaceAll,Object.hasOwn, and a regex test optimization). - Tighten date validation helpers and adjust
Errors.get()lookup condition.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/string.ts | Refactors formatter to use replaceAll and optimizes snake_case detection. |
| src/utils/object.ts | Switches hasOwnProperty implementation to Object.hasOwn. |
| src/utils/date.ts | Makes helper functions private and tightens isValidDate typing/flow. |
| src/errors.ts | Adjusts get() to use some() for presence detection. |
| package.json | Updates pnpm version pin and bumps dependency versions. |
| pnpm-lock.yaml | Lockfile refresh reflecting dependency updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates dependencies/tooling and refactors a few utility helpers to use newer platform APIs, while tightening date validation typing and internal helpers.
Changes:
- Refactor string/object utilities (
replaceAll,Object.hasOwn, regex.test) and streamline anErrors.getcheck. - Refactor date validation internals and narrow
isValidDate’s TypeScript signature. - Bump pnpm/Node engine requirements and update dependency/devDependency versions; align CI pnpm version.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/string.ts | Switches to newer string/regex patterns (replaceAll, .test) in formatting/snake-case helpers. |
| src/utils/object.ts | Replaces Object.prototype.hasOwnProperty.call with Object.hasOwn. |
| src/utils/date.ts | Makes leap-year/false-positive checks internal and narrows isValidDate typing. |
| src/errors.ts | Replaces find-based truthiness check with some (but still re-finds). |
| package.json | Updates pnpm pin, raises Node engine, bumps deps/devDeps versions. |
| .github/workflows/ci.yml | Updates pnpm version used in CI to match packageManager pin. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates dependencies/tooling (pnpm, Node engine, lint/test deps) and refactors a few utility helpers used throughout the validator, including object property checks and date validation logic (linked to issue #1110).
Changes:
- Refactor utils (
hasOwnProperty, string formatting, date helpers) and simplifyErrors.get. - Bump Node engine requirement and update pnpm version used locally and in CI.
- Upgrade runtime/dev dependencies (e.g., lodash-es, eslint, vitest).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/utils/string.ts |
Switches to replaceAll and simplifies uppercase detection in toSnakeCase. |
src/utils/object.ts |
Updates hasOwnProperty signature and implementation to use Object.hasOwn. |
src/utils/date.ts |
Refactors date helper functions and tightens isValidDate typing/flow. |
src/errors.ts |
Avoids duplicate .find() calls when retrieving errors for a field. |
package.json |
Updates Node engine requirement, pnpm version pin, and dependency versions. |
.github/workflows/ci.yml |
Aligns CI pnpm version with the repo’s pinned pnpm version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…irement to >=20.19.0
820c97e to
4f73135
Compare
… and upgrade pnpm to 10.33.1
There was a problem hiding this comment.
Pull request overview
This PR updates project dependencies/tooling (pnpm, eslint, etc.) and refactors a few utilities to use newer built-ins while tightening date validation behavior.
Changes:
- Upgraded dependencies and tooling (package.json + pnpm-lock) and updated CI Node/pnpm versions.
- Replaced custom own-property checks with
Object.hasOwnin validator path traversal. - Refactored date validation helpers and simplified
Errors.get()implementation.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/string.ts | Minor refactor to use regex .test() before replacement. |
| src/utils/object.ts | Removed hasOwnProperty helper export (no longer used internally). |
| src/utils/date.ts | Made helper functions internal and adjusted isValidDate typing/normalization. |
| src/main.ts | Switched own-property checking to Object.hasOwn during nested attribute traversal. |
| src/errors.ts | Avoided duplicate find() calls in Errors.get(). |
| tests/utils.spec.ts | Removed hasOwnProperty tests; kept minimal isValidDate tests. |
| .github/workflows/ci.yml | Updated CI matrix Node versions and pnpm version. |
| package.json | Bumped deps/tools, updated pnpm version pin, and raised Node engine requirement. |
| pnpm-lock.yaml | Lockfile updated to reflect dependency/tooling upgrades. |
Comments suppressed due to low confidence (1)
tests/utils.spec.ts:9
isValidDatebehavior was updated (numeric timestamp checks + stricter string handling), but the test cases don't cover the date-string false-positive logic (e.g., Feb 29 on non-leap years, months with 30 days) or the new multi-separator normalization (.and/). Adding a few representative cases (valid/invalid leap-year dates,YYYY/MM/DD,YYYY.MM.DD, and invalid day/month combinations) would help prevent regressions.
describe('isValidDate', () => {
it('should return false for empty string', () => {
expect(isValidDate('')).toBeFalsy()
})
it('should return false for whitespace-only string', () => {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates dependencies/tooling and refactors a few core utilities/validators, including a more robust isValidDate implementation and modernized object property checks, while adding tests to cover new/previously-uncovered branches.
Changes:
- Update dependencies (incl. ESLint config) and bump Node.js engine requirement; align CI and pnpm versions.
- Refactor utils: broaden string formatter inputs, remove custom
hasOwnPropertyhelper, and improve date validation behavior. - Add/extend test coverage for wildcard handling, async validation branching, numeric parameter parsing, and date parsing edge cases.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/string.ts | Accept number/string inputs for formatting/casing helpers; minor regex optimization. |
| src/utils/object.ts | Remove custom hasOwnProperty helper (relies on built-ins elsewhere). |
| src/utils/date.ts | Make date validation stricter and support Date instances explicitly. |
| src/rules/required.ts | Minor formatting/flow simplification. |
| src/rules/ipv4.ts | Formatting-only refactor. |
| src/rules/ipv6.ts | Formatting-only refactor. |
| src/rule.ts | Adjust in rule signature/flow and related formatting. |
| src/main.ts | Replace property check with Object.hasOwn; widen typing in _parseRulesDefault; wildcard-related logic covered by new tests. |
| src/errors.ts | Simplify field normalization and improve lookup logic for camel/snake variants. |
| src/async-resolvers.ts | Formatting-only refactor. |
| package.json | Bump pnpm, dependencies, and Node engine requirement (breaking change). |
| pnpm-lock.yaml | Lockfile updates for dependency bumps. |
| tests/wildcard.spec.ts | Add coverage for null wildcard parent and _replaceWildCards early return. |
| tests/validator.spec.ts | Add coverage for confirmedReverse and async “not validatable” branch. |
| tests/utils.spec.ts | Remove hasOwnProperty tests; expand isValidDate tests. |
| tests/required_without_all.spec.ts | Add coverage for numeric rule value parsing branch. |
| tests/date.spec.ts | Add additional valid date cases to exercise false-positive protection. |
| .github/workflows/ci.yml | Switch CI Node version and pnpm version to match updated tooling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e from rulesArray parameter
Linked Issue
Resolved #1110