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 => {
if (val === null || val === undefined) return val;
if (val instanceof Date) return val;
const date = new Date(val);
if (!isNaN(date.getTime())) return date;
if (typeof val === 'string') return val.toLowerCase();
if (typeof val === 'string') {
const date = new Date(val);
if (!isNaN(date.getTime())) return date;
return val.toLowerCase();
}
return val;
};
const value = normalize(rawValue);
const ruleVal = normalize(rule.value);
const ruleStart = normalize(rule.valueStart);
const ruleEnd = normalize(rule.valueEnd);