Lines 245-285javascript
245 lines.push(`if(d[${k}]==='false'||d[${k}]==='0')d[${k}]=false`);
246 } else if (t === 'array' && options.coerceTypes === 'array') {
247 lines.push(`if(${k} in d&&d[${k}]!==undefined&&!Array.isArray(d[${k}]))d[${k}]=[d[${k}]]`);
252 // defaults: inline per property
253 for (const [key, prop] of Object.entries(props)) {
254 if (prop && typeof prop === 'object' && prop.default !== undefined) {
255 const k = JSON.stringify(key);
256 const def = JSON.stringify(prop.default);
257 lines.push(`if(!(${k} in d))d[${k}]=${def}`);
261 if (lines.length === 0) return null;
262 // Data may legitimately be null or a non-object (e.g. a `['object','null']`
263 // schema), so the per-property mutations must not run on it.
264 lines.unshift(`if(d===null||typeof d!=='object')return`);
266 return new Function('d', lines.join('\n'));
267 } catch {
LowEval
Package source references a known benign dynamic code generation pattern.
index.jsView on unpkg · L265 272// Schema compilation cache: same schema string -> reuse compiled functions
273const _compileCache = new Map();
275// Object identity cache: same schema object reference -> reuse entire compiled state
276// Skips JSON.stringify, cache lookup, and all setup. Near-zero cost for repeated schemas.
277const _identityCache = new WeakMap();
279const SIMDJSON_PADDING = 64;
280const VALID_RESULT = Object.freeze({ valid: true, errors: Object.freeze([]) });
281const ABORT_EARLY_RESULT = Object.freeze({
283 errors: Object.freeze([Object.freeze({
285 message: 'validation failed',