@izara_project/izara-core-library-asynchronous-flow 1.0.5 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-library-asynchronous-flow",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Shared asynchronous flow logic",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -817,21 +817,24 @@ module.exports.validateStartKeyParam = (
817
817
  _izContext,
818
818
  startKey,
819
819
  partitionKeyFieldName,
820
- sortKeyFieldName = null
820
+ sortKeyFieldName
821
821
  ) => {
822
+ const stringNotEmptyRegex = /^[A-Za-z0-9_-]+$/;
823
+
824
+ if (
825
+ !partitionKeyFieldName || !sortKeyFieldName
826
+ || !stringNotEmptyRegex.test(partitionKeyFieldName)
827
+ || !stringNotEmptyRegex.test(sortKeyFieldName)
828
+ ) {
829
+ throw new NoRetryError("validateStartKeyParam: Invalid partitionKeyFieldName or sortKeyFieldName");
830
+ }
822
831
 
823
832
  if (startKey && Object.keys(startKey).length != 0) {
824
- if (
825
- startKey.constructor !== Object ||
826
- !startKey[partitionKeyFieldName]
827
- ) {
828
- startKey = false; // we can type check for false to see if invalid
829
- }
830
- if (sortKeyFieldName !== null && sortKeyFieldName !== undefined && !startKey[sortKeyFieldName]) {
831
- startKey = false;
833
+ if (!startKey[partitionKeyFieldName] || !startKey[sortKeyFieldName]) {
834
+ throw new NoRetryError("validateStartKeyParam: Invalid startKey, missing partitionKeyFieldName or sortKeyFieldName");
832
835
  }
833
836
  } else {
834
- startKey = null; // if empty set to null so lib functions process correctly (not want empty object)
837
+ startKey = null; // if empty set to null so lib functions process correctly
835
838
  }
836
839
 
837
840
  return startKey;