UNPKG

@edirect/form-engine

Version:

Achieve form logic reusage with forms expressed in json format.

21 lines (20 loc) 550 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasJsonStructure = hasJsonStructure; exports.hasTemplate = void 0; function hasJsonStructure(str) { if (typeof str !== 'string') return false; try { const result = JSON.parse(str); const type = Object.prototype.toString.call(result); return type === '[object Object]' || type === '[object Array]'; } catch (err) { return false; } } const hasTemplate = value => { return /\$\{(.*)\}.*/g.test(value); }; exports.hasTemplate = hasTemplate;