@jarenjs/forms 0.72.2 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -120,7 +120,7 @@ depends on it — the schema is the contract.
120
120
  - **enum/const**: deep equality (`equalsDeep`)
121
121
  - **arrays**: `minItems`/`maxItems`/`uniqueItems` (`isUniqueDeepArray`)
122
122
 
123
- `validateAllFields(model, data)` walks the whole tree and returns a `{ '/pointer': errors }` map — ideal for rendering inline errors next to every field.
123
+ `validateAllFields(model, data)` walks the whole tree and returns a `{ '/pointer': errors }` map — ideal for rendering inline errors next to every field. It reads own JSON members, like the pointer helpers: a field named `constructor`, `toString` or `__proto__` is absent until the data supplies that member.
124
124
 
125
125
  ## Layer 2 — `x-form` rules: cross-field behavior per keystroke
126
126
 
@@ -30,7 +30,7 @@ export type FieldError = {
30
30
  */
31
31
  export declare function validateField(field: import('./model.js').FormField, value: any, catalog?: Readonly<Record<string, (params: object, error?: object) => string>>): FieldError[];
32
32
  /**
33
- * Validate every leaf field of a model against the current data.
33
+ * Validate every field of a model against the current data's own JSON members.
34
34
  * Returns a map of data-pointer -> FieldError[] for fields that fail.
35
35
  * @param {import('./model.js').FormField} model - Root field from buildFormModel
36
36
  * @param {any} data - Current form data
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jarenjs/forms",
3
3
  "private": false,
4
- "version": "0.72.2",
4
+ "version": "0.73.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -47,9 +47,9 @@
47
47
  "prepack": "npm run build:types"
48
48
  },
49
49
  "dependencies": {
50
- "@jarenjs/core": "^0.72.2",
51
- "@jarenjs/formats": "^0.72.2",
52
- "@jarenjs/json": "^0.72.2",
53
- "@jarenjs/validate": "^0.72.2"
50
+ "@jarenjs/core": "^0.73.0",
51
+ "@jarenjs/formats": "^0.73.0",
52
+ "@jarenjs/json": "^0.73.0",
53
+ "@jarenjs/validate": "^0.73.0"
54
54
  }
55
55
  }
package/src/validate.js CHANGED
@@ -229,7 +229,7 @@ export function validateField(field, value, catalog = undefined) {
229
229
  }
230
230
 
231
231
  /**
232
- * Validate every leaf field of a model against the current data.
232
+ * Validate every field of a model against the current data's own JSON members.
233
233
  * Returns a map of data-pointer -> FieldError[] for fields that fail.
234
234
  * @param {import('./model.js').FormField} model - Root field from buildFormModel
235
235
  * @param {any} data - Current form data
@@ -252,7 +252,8 @@ function walkFields(field, value, pointer, result, catalog) {
252
252
  // RFC 6901-encoded, the walk convention shared with the model
253
253
  // and rule pointers — a member name containing '/' or '~' stays
254
254
  // addressable and never collides with a nested path
255
- walkFields(child, value[child.key], `${pointer}/${encodeJSONPointerSegment(child.key)}`, result, catalog);
255
+ const childValue = Object.hasOwn(value, child.key) ? value[child.key] : undefined;
256
+ walkFields(child, childValue, `${pointer}/${encodeJSONPointerSegment(child.key)}`, result, catalog);
256
257
  }
257
258
  }
258
259
  else if (field.kind === 'array' && Array.isArray(value)) {