MCPcopy Create free account
hub / github.com/json-editor/json-editor / ajustIMaskOptions

Method ajustIMaskOptions

src/editors/string.js:270–287  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

268 }
269
270 ajustIMaskOptions (obj) {
271 /* iMask config format is not JSON friendly, so function and regex based mask */
272 /* properties have to be adjusted from string to the correct format */
273 Object.keys(obj).forEach(prop => {
274 if (obj[prop] === Object(obj[prop])) obj[prop] = this.ajustIMaskOptions(obj[prop])
275 else if (prop === 'mask') {
276 if (obj[prop].substr(0, 6) === 'regex:') {
277 const regExMatch = obj[prop].match(/^regex:\/(.*)\/([gimsuy]*)$/)
278 if (regExMatch !== null) {
279 try {
280 obj[prop] = new RegExp(regExMatch[1], regExMatch[2])
281 } catch (e) { }
282 }
283 } else obj[prop] = this.getGlobalPropertyFromString(obj[prop])
284 }
285 })
286 return obj
287 }
288
289 getGlobalPropertyFromString (strValue) {
290 if (!strValue.includes('.')) {

Callers 1

setupImaskMethod · 0.95

Calls 1

Tested by

no test coverage detected