ata-validator 1.33.0 → 1.33.1

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/index.js CHANGED
@@ -2943,12 +2943,18 @@ Validator.prototype.parse = function (data) {
2943
2943
  };
2944
2944
 
2945
2945
  function _buildParse(self) {
2946
- const decline = (why) => () => {
2947
- throw new TypeError(`parse() is not available for this validator: ${why}. Use validate() with removeAdditional instead.`);
2946
+ const decline = (why, instead = 'Use validate() with removeAdditional instead.') => () => {
2947
+ throw new TypeError(`parse() is not available for this validator: ${why}. ${instead}`);
2948
2948
  };
2949
2949
  const o = self._options;
2950
- if (o.coerceTypes || o.removeAdditional === 'all' || self._usesKeywords || self._verdictTail !== null || self._validateTail !== null) {
2951
- return decline('its options or keywords rewrite or extend what the schema checks');
2950
+ // Each refusal names its own reason: a caller who hit the combined one could
2951
+ // not tell a coercion option from a keyword package, and read a deliberate
2952
+ // refusal as a failure of valid data.
2953
+ if (o.coerceTypes) return decline('coerceTypes rewrites the input before it is checked');
2954
+ if (o.removeAdditional === 'all') return decline("removeAdditional: 'all' decides the kept keys at check time");
2955
+ if (self._usesKeywords) return decline('custom keywords are in use, and what they accept is not known to the copy');
2956
+ if (self._verdictTail !== null || self._validateTail !== null) {
2957
+ return decline('checks were added to this validator (for example by withKeywords from @ata-project/keywords), and a value they accept, such as a Date, has no copy the schema can describe', 'Use validate(); a valid result carries the input as it is.');
2952
2958
  }
2953
2959
  const { cloneExprFor } = require('./lib/clone-emit');
2954
2960
  const expr = cloneExprFor(self._schemaObj);
@@ -1002,9 +1002,13 @@ function withPlain (schema, v, lines, ctx, run) {
1002
1002
  // The same test at run time, for the closure compiler.
1003
1003
  const _hop = Object.prototype.hasOwnProperty
1004
1004
  const _PN = ({}).__proto__ === Object.prototype
1005
+ // One hasOwnProperty call. From 1.31.2 to 1.33.0 this first tested the name
1006
+ // against Object.prototype's names, then `in`, then read the prototype through
1007
+ // the __proto__ accessor, on every property of every object the eval-free
1008
+ // engine checked: a schema of 14 properties went from 641 to 828 ns a verdict.
1009
+ // hasOwnProperty gives the same answer and V8 inlines it.
1005
1010
  function hasOwnKey (d, key) {
1006
- if (PROTO_NAMES.has(key)) return _hop.call(d, key)
1007
- return key in d && ((_PN ? d.__proto__ : Object.getPrototypeOf(d)) === Object.prototype || _hop.call(d, key))
1011
+ return _hop.call(d, key)
1008
1012
  }
1009
1013
 
1010
1014
  const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'toString', 'valueOf',
package/lib/version.js CHANGED
@@ -7,4 +7,4 @@
7
7
  //
8
8
  // Kept in lockstep with package.json by `tests/test_version_sync.js`.
9
9
 
10
- module.exports = '1.33.0';
10
+ module.exports = '1.33.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "1.33.0",
3
+ "version": "1.33.1",
4
4
  "description": "JSON Schema validation that compiles for speed and still runs where code generation is blocked. Compiled and interpreted engines answer identically at 100% of the official suite. TypeScript inference, Standard Schema V1, and a build step that emits dependency-free modules.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -121,13 +121,13 @@
121
121
  "LICENSE"
122
122
  ],
123
123
  "optionalDependencies": {
124
- "@ata-validator/native-darwin-arm64": "1.33.0",
125
- "@ata-validator/native-darwin-x64": "1.33.0",
126
- "@ata-validator/native-linux-arm64-gnu": "1.33.0",
127
- "@ata-validator/native-linux-arm64-musl": "1.33.0",
128
- "@ata-validator/native-linux-x64-gnu": "1.33.0",
129
- "@ata-validator/native-linux-x64-musl": "1.33.0",
130
- "@ata-validator/native-win32-x64": "1.33.0"
124
+ "@ata-validator/native-darwin-arm64": "1.33.1",
125
+ "@ata-validator/native-darwin-x64": "1.33.1",
126
+ "@ata-validator/native-linux-arm64-gnu": "1.33.1",
127
+ "@ata-validator/native-linux-arm64-musl": "1.33.1",
128
+ "@ata-validator/native-linux-x64-gnu": "1.33.1",
129
+ "@ata-validator/native-linux-x64-musl": "1.33.1",
130
+ "@ata-validator/native-win32-x64": "1.33.1"
131
131
  },
132
132
  "peerDependencies": {
133
133
  "yaml": "^2.0.0"