Skip to content

fix(isMACAddress): preserve caller EUI options - #2925

Open
FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/mac-address-frozen-options-20261010
Open

FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/mac-address-frozen-options-20261010

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 9, 2026

Copy link
Copy Markdown

isMACAddress('01:23:45:67:89:ab', Object.freeze({ eui: 48 })) throws instead of returning a boolean. The function writes its normalized EUI value back into the caller's options, even when the supplied value is already a string. It also changes a mutable options object's numeric eui to a string.

Normalize EUI into a local variable and use it for the existing comparisons. Validation rules remain unchanged. Regression coverage checks frozen numeric/string EUI-48 and EUI-64 options, the no_separators and legacy no_colons options, valid/invalid addresses and preservation of a mutable options object.

Validation on Linux / Node 24.19.0:

  • Full unchanged npm test: 323 passing.
  • Full tests with regressions and original source: 323 passing, 2 failing.
  • Final npm test: 325 passing, including all builds, minification, ESLint and coverage.
  • 6,300 additional assertions across six source/generated entry points confirm frozen-option results match mutable-option results.
  • git diff --check passes.

Statement, function and line coverage remain 100%. Branch coverage changes from 96.59% (1697/1757) to 96.57% (1689/1749), because eight covered branches disappear when repeated optional chaining is replaced by the local variable; the number of uncovered branches stays 60. The remote Node-version CI matrix has not been run locally.

AI assistance was used to prepare the implementation and regression tests.

Checklist

  • Only related source and regression-test changes
  • README reviewed; existing API and validation options are unchanged
  • Regression tests added
  • References: reproduction uses the existing documented options

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 9, 2026 21:30
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.

1 participant