diff --git a/libs/stringsInArray.js b/libs/stringsInArray.js index d7d78e4d..7fb273de 100644 --- a/libs/stringsInArray.js +++ b/libs/stringsInArray.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.stringsInArray = stringsInArray; exports.someInArray = someInArray; exports.extractFieldValues = extractFieldValues; +const isValue_1 = require("../utils/isValue"); /** * @notused */ @@ -26,9 +27,14 @@ function stringsInArray(check, array) { } } function someInArray(check, array) { + if (!(0, isValue_1.isValue)(check)) + return false; if (typeof check === 'string') { check = [check]; } + else if (!Array.isArray(check)) { + return false; + } return array.some((e) => check.includes(e)); } function extractFieldValues(obj, fields, exclude = true, result = []) { diff --git a/libs/stringsInArray.ts b/libs/stringsInArray.ts index 518fbe89..b653b81c 100644 --- a/libs/stringsInArray.ts +++ b/libs/stringsInArray.ts @@ -1,3 +1,5 @@ +import { isValue } from "../utils/isValue"; + /** * @notused */ @@ -22,8 +24,12 @@ export function stringsInArray(check: string[] | string, array: string[]): boole } export function someInArray(check: string[] | string, array: string[]) { + if(!isValue(check)) return false; + if (typeof check === 'string') { check = [check]; + } else if(!Array.isArray(check)) { + return false; } return array.some((e)=> check.includes(e)); diff --git a/models/Order.ts b/models/Order.ts index db2b9df3..18f068dd 100644 --- a/models/Order.ts +++ b/models/Order.ts @@ -1559,7 +1559,7 @@ let Model = { await Order.update({ id: order.id }, promotionOrderToSave).fetch(); } catch (error) { - sails.log.error(`Core > order > promotion calculate fail: `, error) + sails.log.error(`Core > order > promotion calculate fail: `, error); } finally { // finally order.isPromoting = false;