diff --git a/lib/org-rules.cjs b/lib/org-rules.cjs index 9b3802c..cb424bf 100644 --- a/lib/org-rules.cjs +++ b/lib/org-rules.cjs @@ -187,7 +187,7 @@ const selectionForTags = (tags, serviceDefinition) => { const caseSensitiveFieldListMatch = (fieldName) => (value, serviceDefinition) => { - if (value.toLocaleLowerCase() === 'all') { + if (value?.toLocaleLowerCase() === 'all') { !!_.get(serviceDefinition, fieldName, undefined) } if (!Array.isArray(value)) { @@ -210,7 +210,7 @@ const caseSensitiveFieldListMatch = * @function **/ const caseInsensitiveFieldMatch = (fieldName) => (value, serviceDefinition) => - value.toLocaleLowerCase() === + value?.toLocaleLowerCase() === serviceDefinition?.[fieldName]?.toLocaleLowerCase() /** @@ -239,7 +239,7 @@ const determineApplicabilityOfRule = (rule, serviceDescription) => { if (!selectionCriteria) return false - if (`${selectionCriteria}`.toLocaleLowerCase() === 'all') return true + if (`${selectionCriteria}`?.toLocaleLowerCase() === 'all') return true // Find all of the criteria which fail. const failingCriteria = _.filter(selectionCriteria, (value, key) => { @@ -330,7 +330,7 @@ const makeComplianceCheck_valueMatchAndCount = ( if ( permittedValues.length && !sd_list.find((value) => - _.includes(permittedValues, matchField_sd(value).toLocaleLowerCase()), + _.includes(permittedValues, matchField_sd(value)?.toLocaleLowerCase()), ) ) { return false @@ -355,7 +355,7 @@ const makeSimpleStringFieldComplianceChecker = // Support `any` if ( !Array.isArray(requirement) && - requirement.toLocaleLowerCase() === 'any' + requirement?.toLocaleLowerCase() === 'any' ) { return !!_.get(serviceDefinition, fieldName, undefined) }