Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: seanpmaxwell/jet-validators
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9117287c648ea7a540391639c28b31ab7bef72c0
Choose a base ref
...
head repository: seanpmaxwell/jet-validators
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3f72876bbd2fac56030612c593ae4a9d7be555e0
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Mar 21, 2025

  1. Copy the full SHA
    3f72876 View commit details
Showing with 10 additions and 3 deletions.
  1. +1 −1 package.json
  2. +9 −2 utils/src/parseObject.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jet-validators",
"version": "1.3.9",
"version": "1.4.0",
"description": "A list common typescript validator-functions and some useful utilities to go with them.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
11 changes: 9 additions & 2 deletions utils/src/parseObject.ts
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ const ERRORS = {
ValidatorFn: 'Validator-function returned false.',
ErrorThrown: 'Validator function threw an error.',
StrictSafety: 'strict-safety failed, prop not in schema.',
SchemaProp: 'Schema property must be a function or nested schema',
} as const;


@@ -395,7 +396,7 @@ function _parseObjectHelperWithErrCb2(
});
}
// Nested schema
} else {
} else if (isRecord(schemaProp) && Object.keys(schemaProp).length > 0) {
const childErrArr: IParseObjectError[] = [],
childVal = _parseObjectHelperWithErrCb2(schemaProp, val, childErrArr,
safety);
@@ -407,6 +408,9 @@ function _parseObjectHelperWithErrCb2(
...(isUndef(index) ? {} : { index }),
});
}
// Throw error if not function
} else {
throw new Error(ERRORS.SchemaProp);
}
}
// Unless safety = "loose", filter extra keys
@@ -506,11 +510,14 @@ function _parseObjectHelperWoErrCb2(
return false;
}
// Nested schema
} else {
} else if (isRecord(schemaProp) && Object.keys(schemaProp).length > 0) {
const childVal = _parseObjectHelperWoErrCb2(schemaProp, val, safety);
if (childVal === false) {
return false;
}
// Throw error if not function or nested schema
} else {
throw new Error(ERRORS.SchemaProp);
}
}
// Unless safety = "loose", filter extra keys