Skip to content

fix(isIn): check object membership without calling shadowed methods - #2929

Open
FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix-is-in-own-properties-20261012
Open

FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix-is-in-own-properties-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown

isIn supports object own-key membership, but it calls the object's hasOwnProperty value as a method. A null-prototype dictionary throws; a dictionary containing a hasOwnProperty key can throw or report incorrect membership.

Use Object.prototype.hasOwnProperty.call, matching the existing array branch. Add three regressions covering null prototypes, a non-callable method-name key, and an overridden method that falsely reports every key as present. Inherited keys remain excluded. No dependencies, generated distributions, or unrelated behavior are changed.

Validation on Linux:

  • Pristine full npm test: 323 passing on Node 24.19.0, including builds, minification, ESLint and coverage.
  • The three added regressions fail on unchanged source and pass after the fix.
  • Final full npm test: 326 passing on both Node 24.19.0 and 22.19.0; all build/lint gates pass. Coverage is unchanged (100% statements/functions/lines; 96.59% branches).
  • 3,390 additional checks across source, CommonJS, ES-module and browser distributions cover prototypes, shadowed keys, property descriptors, frozen objects, and array/string compatibility.
  • git diff --check passes. Other CI runtimes were not run locally; hosted CI results are separate.

Object membership is established by the existing object tests and PR #336.

Checklist

  • Changes are limited to the object-membership fix and its tests.
  • README reviewed; no documented API or options changed.
  • Regression tests included.
  • Existing API reference linked above.

Prepared and tested with OpenAI Codex assistance. No human review or hosted CI pass is claimed.

Use the intrinsic own-property check for null-prototype dictionaries and
objects containing a hasOwnProperty key. Add regression coverage.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 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