Ensure Magic Shelf correctly evaluates rules with fractional numeric values (#1110)

This commit is contained in:
Aditya Chandel
2025-09-07 11:36:31 -06:00
committed by GitHub
parent 8aa3dfffc8
commit f39e1b264b
@@ -22,14 +22,15 @@ export class BookRuleEvaluatorService {
const normalize = (val: any): any => { const normalize = (val: any): any => {
if (val === null || val === undefined) return val; if (val === null || val === undefined) return val;
if (val instanceof Date) return val; if (val instanceof Date) return val;
const date = new Date(val); if (typeof val === 'string') {
if (!isNaN(date.getTime())) return date; const date = new Date(val);
if (typeof val === 'string') return val.toLowerCase(); if (!isNaN(date.getTime())) return date;
return val.toLowerCase();
}
return val; return val;
}; };
const value = normalize(rawValue); const value = normalize(rawValue);
const ruleVal = normalize(rule.value); const ruleVal = normalize(rule.value);
const ruleStart = normalize(rule.valueStart); const ruleStart = normalize(rule.valueStart);
const ruleEnd = normalize(rule.valueEnd); const ruleEnd = normalize(rule.valueEnd);