Skip to content

Commit 0678f4b

Browse files
committed
Support more
1 parent cb6d284 commit 0678f4b

File tree

3 files changed

+15
-68
lines changed

3 files changed

+15
-68
lines changed

debug-properties.test.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

failing-tests-skip-list.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
"if-then-else|validate against correct branch, then vs else|invalid through else",
6363
"if-then-else|validate against correct branch, then vs else|invalid through then",
6464
"infinite-loop-detection|evaluating the same schema location against the same data location twice is not a sign of an infinite loop|failing case",
65+
"not|collect annotations inside a 'not', even if collection is disabled|unevaluated property",
6566
"items|items and subitems|too many sub-items",
6667
"items|items and subitems|wrong item",
6768
"items|items and subitems|wrong sub-item",
68-
"not|collect annotations inside a 'not', even if collection is disabled|unevaluated property",
6969
"ref|$id must be resolved against nearest parent, not just immediate parent|non-number is invalid",
7070
"ref|empty tokens in $ref json-pointer|non-number is invalid",
7171
"vocabulary|schema that uses custom metaschema with with no validation vocabulary|no validation: invalid number, but it still validates",
@@ -82,16 +82,9 @@
8282
"patternProperties|patternProperties with boolean schemas|object with property matching schema false is invalid",
8383
"patternProperties|regexes are not anchored by default and are case sensitive|recognized members are accounted for",
8484
"patternProperties|regexes are not anchored by default and are case sensitive|regexes are case sensitive, 2",
85-
"prefixItems|a schema given for prefixItems|wrong types",
86-
"prefixItems|prefixItems with boolean schemas|array with two items is invalid",
87-
"properties|object properties validation|both properties invalid is invalid",
88-
"properties|object properties validation|one property invalid is invalid",
8985
"properties|properties whose names are Javascript object property names|__proto__ not valid",
9086
"properties|properties whose names are Javascript object property names|constructor not valid",
9187
"properties|properties whose names are Javascript object property names|toString not valid",
92-
"properties|properties with boolean schema|both properties present is invalid",
93-
"properties|properties with boolean schema|only 'false' property present is invalid",
94-
"properties|properties with escaped characters|object with strings is invalid",
9588
"properties|properties, patternProperties, additionalProperties interaction|additionalProperty invalidates others",
9689
"properties|properties, patternProperties, additionalProperties interaction|patternProperty invalidates nonproperty",
9790
"properties|properties, patternProperties, additionalProperties interaction|patternProperty invalidates property",

src/handlers/refinement/objectProperties.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,17 @@ export class ObjectPropertiesHandler implements RefinementHandler {
5959
// Apply properties constraint
6060
if (objectSchema.properties) {
6161
for (const [propName, propSchema] of Object.entries(objectSchema.properties)) {
62-
if (Object.prototype.hasOwnProperty.call(value, propName) && propSchema !== undefined) {
63-
const zodPropSchema = convertJsonSchemaToZod(propSchema);
64-
if (!zodPropSchema.safeParse(value[propName]).success) {
65-
return false;
62+
if (propSchema !== undefined) {
63+
// Use a more robust way to check if property exists
64+
// This handles JavaScript special property names correctly
65+
const propExists = Object.getOwnPropertyDescriptor(value, propName) !== undefined;
66+
67+
if (propExists) {
68+
const zodPropSchema = convertJsonSchemaToZod(propSchema);
69+
const propResult = zodPropSchema.safeParse(value[propName]);
70+
if (!propResult.success) {
71+
return false;
72+
}
6673
}
6774
}
6875
}
@@ -71,7 +78,9 @@ export class ObjectPropertiesHandler implements RefinementHandler {
7178
// Apply required constraint
7279
if (objectSchema.required && Array.isArray(objectSchema.required)) {
7380
for (const requiredProp of objectSchema.required) {
74-
if (!Object.prototype.hasOwnProperty.call(value, requiredProp)) {
81+
// Use robust property detection for required props too
82+
const propExists = Object.getOwnPropertyDescriptor(value, requiredProp) !== undefined;
83+
if (!propExists) {
7584
return false;
7685
}
7786
}

0 commit comments

Comments
 (0)