|
@@ -1,4 +1,4 @@
|
|
|
-// Some standard utility functions for Dyynaform consumers
|
|
|
+// Utility functions for Dyynaform consumers
|
|
|
|
|
|
import { ValueTransformer } from './interfaces';
|
|
|
|
|
@@ -8,20 +8,20 @@ const standardTransformer: ValueTransformer = {
|
|
|
inputFn: val => {
|
|
|
let modifier = 'Starts with';
|
|
|
if (/^%.*?%$/.test(val)) {
|
|
|
- modifier = 'Contains'
|
|
|
+ modifier = 'Contains';
|
|
|
} else if (/^[^%].*?[^%]$/.test(val)) {
|
|
|
- modifier = 'Matches'
|
|
|
+ modifier = 'Matches';
|
|
|
} else if (/^%.*/.test(val)) {
|
|
|
modifier = 'Starts with';
|
|
|
}
|
|
|
const transformedVal = val.replace(/%/g, '').trim();
|
|
|
- return { modifier: modifier, value: transformedVal };
|
|
|
+ return { modifier, value: transformedVal };
|
|
|
},
|
|
|
outputFn: (mod, val) => {
|
|
|
let transformedValue;
|
|
|
- switch(mod) {
|
|
|
+ switch (mod) {
|
|
|
case 'Starts with':
|
|
|
- transformedValue = `%${val}`;
|
|
|
+ transformedValue = `${val}%`;
|
|
|
break;
|
|
|
case 'Contains':
|
|
|
transformedValue = `%${val}%`;
|
|
@@ -52,6 +52,6 @@ const excludeFields = (obj: StringMap, fieldsToExclude: string | string[]) => {
|
|
|
(res, [key, val]) => ex.includes(key) ? res : { ...res, [key]: val },
|
|
|
{}
|
|
|
);
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
export { standardModifiers, standardTransformer, toArrTag, arrayPad, arrayToMeta, excludeFields };
|