Browse Source

feat: add contains and not contains case insensitive

Ahmad Kholid 2 years ago
parent
commit
bc58714440
2 changed files with 15 additions and 0 deletions
  1. 12 0
      src/utils/shared.js
  2. 3 0
      src/utils/testConditions.js

+ 12 - 0
src/utils/shared.js

@@ -1483,7 +1483,19 @@ export const conditionBuilder = {
       category: 'number',
     },
     { id: 'cnt', name: 'Contains', needValue: true, category: 'text' },
+    {
+      id: 'cni',
+      name: 'Contains (case insensitive)',
+      needValue: true,
+      category: 'text',
+    },
     { id: 'nct', name: 'Not contains', needValue: true, category: 'text' },
+    {
+      id: 'nci',
+      name: 'Not contains (case insensitive)',
+      needValue: true,
+      category: 'text',
+    },
     { id: 'stw', name: 'Starts with', needValue: true, category: 'text' },
     { id: 'enw', name: 'Ends with', needValue: true, category: 'text' },
     { id: 'rgx', name: 'Match with RegEx', needValue: true, category: 'text' },

+ 3 - 0
src/utils/testConditions.js

@@ -18,7 +18,10 @@ const comparisons = {
   lt: (a, b) => isNumStr(a) < isNumStr(b),
   lte: (a, b) => isNumStr(a) <= isNumStr(b),
   cnt: (a, b) => a?.includes(b) ?? false,
+  cni: (a, b) =>
+    a?.toLocaleLowerCase().includes(b?.toLocaleLowerCase()) ?? false,
   nct: (a, b) => !comparisons.cnt(a, b),
+  nci: (a, b) => !comparisons.cni(a, b),
   stw: (a, b) => a?.startsWith(b) ?? false,
   enw: (a, b) => a?.endsWith(b) ?? false,
   rgx: (a, b) => {