فهرست منبع

feat: add `equals (case insensitive)` in conditions block

Ahmad Kholid 2 سال پیش
والد
کامیت
7235d44bf1
2فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 6 0
      src/utils/shared.js
  2. 1 0
      src/utils/testConditions.js

+ 6 - 0
src/utils/shared.js

@@ -1206,6 +1206,12 @@ export const conditionBuilder = {
   ],
   compareTypes: [
     { id: 'eq', name: 'Equals', needValue: true, category: 'basic' },
+    {
+      id: 'eqi',
+      name: 'Equals (case insensitive)',
+      needValue: true,
+      category: 'basic',
+    },
     { id: 'nq', name: 'Not equals', needValue: true, category: 'basic' },
     { id: 'gt', name: 'Greater than', needValue: true, category: 'number' },
     {

+ 1 - 0
src/utils/testConditions.js

@@ -11,6 +11,7 @@ const isBoolStr = (str) => {
 const isNumStr = (str) => (Number.isNaN(+str) ? str : +str);
 const comparisons = {
   eq: (a, b) => a === b,
+  eqi: (a, b) => a?.toLocaleLowerCase() === b?.toLocaleLowerCase(),
   nq: (a, b) => a !== b,
   gt: (a, b) => isNumStr(a) > isNumStr(b),
   gte: (a, b) => isNumStr(a) >= isNumStr(b),