Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Configure JsonLogic
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
// Retrieve Any Date
jsonLogic.add_operation('getDate', (date) => {
return moment(date).toISOString();
});
// Set Relative Minimum Date
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
return moment().subtract(relativeMinDate, 'days').toISOString();
});
// Set Relative Maximum Date
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
return moment().add(relativeMaxDate, 'days').toISOString();
});
export { jsonLogic, moment };
/**
* Evaluate a method.
*
* @param func
* @param args
* @return {*}
*/
export function evaluate(func, args, ret, tokenize) {
let returnVal = null;
const component = args.component ? args.component : { key: 'unknown' };
if (!args.form && args.instance) {
import _ from 'lodash';
import jsonLogic from 'json-logic-js';
import moment from 'moment';
import {lodashOperators} from './jsonlogic/operators';
// Configure JsonLogic
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
// Retrieve Any Date
jsonLogic.add_operation('getDate', (date) => {
return moment(date).toISOString();
});
// Set Relative Minimum Date
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
return moment().subtract(relativeMinDate, 'days').toISOString();
});
// Set Relative Maximum Date
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
return moment().add(relativeMaxDate, 'days').toISOString();
});
const FormioUtils = {
jsonLogic, // Share
// Configure JsonLogic
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
// Retrieve Any Date
jsonLogic.add_operation('getDate', (date) => {
return moment(date).toISOString();
});
// Set Relative Minimum Date
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
return moment().subtract(relativeMinDate, 'days').toISOString();
});
// Set Relative Maximum Date
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
return moment().add(relativeMaxDate, 'days').toISOString();
});
const FormioUtils = {
jsonLogic, // Share
/**
* Determines the boolean value of a setting.
*
* @param value
* @return {boolean}
*/
boolValue(value) {
if (_.isBoolean(value)) {
return value;
}
import _ from 'lodash';
import jsonLogic from 'json-logic-js';
import moment from 'moment';
import {lodashOperators} from './jsonlogic/operators';
// Configure JsonLogic
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
// Retrieve Any Date
jsonLogic.add_operation('getDate', (date) => {
return moment(date).toISOString();
});
// Set Relative Minimum Date
jsonLogic.add_operation('relativeMinDate', (relativeMinDate) => {
return moment().subtract(relativeMinDate, 'days').toISOString();
});
// Set Relative Maximum Date
jsonLogic.add_operation('relativeMaxDate', (relativeMaxDate) => {
return moment().add(relativeMaxDate, 'days').toISOString();
});
const FormioUtils = {
jsonLogic, // Share
/**
* Determines the boolean value of a setting.
*
* @param value
* @return {boolean}
import jsonLogic from 'json-logic-js';
function lowercase(a) {
return a.toLowerCase();
}
function toNumber(a) {
if (typeof a === 'number') {
return a;
} else if (typeof a === 'string') {
return parseInt(a, 10);
}
throw new TypeError(`${a.toString()} is not a number`);
}
jsonLogic.add_operation('lowercase', lowercase);
jsonLogic.add_operation('toNumber', toNumber);
/**
* If in the path [] appears it will be populated
* with current key indices value.
*/
function replaceArrayNotationByIndexes(path, key) {
if (!path || !path.includes('[]')) {
return path;
}
return path
.split(/\.|\[/)
.map((part, index) => {
if (part === ']') {
return key[index];
}
function lowercase(a) {
return a.toLowerCase();
}
function toNumber(a) {
if (typeof a === 'number') {
return a;
} else if (typeof a === 'string') {
return parseInt(a, 10);
}
throw new TypeError(`${a.toString()} is not a number`);
}
jsonLogic.add_operation('lowercase', lowercase);
jsonLogic.add_operation('toNumber', toNumber);
/**
* If in the path [] appears it will be populated
* with current key indices value.
*/
function replaceArrayNotationByIndexes(path, key) {
if (!path || !path.includes('[]')) {
return path;
}
return path
.split(/\.|\[/)
.map((part, index) => {
if (part === ']') {
return key[index];
}
return part;
function lowercase(a) {
return a.toLowerCase();
}
function toNumber(a) {
if (typeof a === 'number') {
return a;
} else if (typeof a === 'string') {
return parseInt(a, 10);
}
throw new TypeError(`${a.toString()} is not a number`);
}
jsonLogic.add_operation('lowercase', lowercase);
jsonLogic.add_operation('toNumber', toNumber);
/**
* If in the path [] appears it will be populated
* with current key indices value.
*/
function replaceArrayNotationByIndexes(path, key) {
if (!path || !path.includes('[]')) {
return path;
}
return path
.split(/\.|\[/)
.map((part, index) => {
if (part === ']') {
return key[index];
}
return part;
import jsonLogic from 'json-logic-js';
function lowercase(a) {
return a.toLowerCase();
}
function toNumber(a) {
if (typeof a === 'number') {
return a;
} else if (typeof a === 'string') {
return parseInt(a, 10);
}
throw new TypeError(`${a.toString()} is not a number`);
}
jsonLogic.add_operation('lowercase', lowercase);
jsonLogic.add_operation('toNumber', toNumber);
/**
* If in the path [] appears it will be populated
* with current key indices value.
*/
function replaceArrayNotationByIndexes(path, key) {
if (!path || !path.includes('[]')) {
return path;
}
return path
.split(/\.|\[/)
.map((part, index) => {
if (part === ']') {
return key[index];
}
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));
lodashOperators.forEach((name) => jsonLogic.add_operation(`_${name}`, _[name]));