Repository navigation
📦🔧:validate a declared constructor property - #112
Conversation
hasInterface skipped every "constructor" key in a validator map, so a
guard for { constructor: number } accepted {} on the strength of its
inherited Object constructor. Skip only a prototype's own back-reference
to its class, and validate a constructor the interface declares.
CodeRabbit raised this when it reviewed #106 after the merge.
Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
Refs: #106
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthrough
ChangesConstructor validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The change adds the intended constructor-property validation while retaining class-instance behavior; no actionable merge-blocking risk is established. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Requested by DerekNonGeneric · project thread
Before:
hasInterface<{ constructor: number }>('X', { constructor: isNumber })returnedtruefor{}, because everyconstructorkey in the validator map was skipped and{}inheritsObjectas its constructor.After: a
constructorthe interface declares is validated like any other property, so{}fails and{ constructor: 1 }passes.How: the walk over the validator map now skips
constructoronly when it is a prototype's own back-reference to its class (proto.constructor.prototype === proto), which is what the skip was for when a class instance is used as the map. A regression test covers the case, and a patch changeset is included for@openinf/util-core.CodeRabbit found this when it reviewed #106 after the merge, on the review-only replay in #109.
Refs: #106
Summary by CodeRabbit
hasInterfacenow validates declaredconstructorproperties, rejecting objects that lack a required constructor value or provide one of the wrong type.