From 03c5ed09f192f3b73d380dcae872a25d4d51cd36 Mon Sep 17 00:00:00 2001 From: Andrea Martella <52160332+Andream98@users.noreply.github.com> Date: Fri, 10 May 2024 09:46:25 +0200 Subject: [PATCH 1/3] Update index.js --- src/index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index f5f51ebd..a11a97a2 100644 --- a/src/index.js +++ b/src/index.js @@ -7,12 +7,22 @@ import FormElement from "./formElement.vue"; import FormGroup from "./formGroup.vue"; const install = (app, options = {}) => { - if (options.fields) { - options.fields.forEach((field) => { - if (typeof field.name !== "undefined") { - Vue.component(field.name, field); + if (options) { + if (options.fields) { + options.fields.forEach((field) => { + if (typeof field.name !== "undefined") { + Vue.component(field.name, field); + } + }); + } + + if (options.validators) { + for (let key in options.validators) { + if ({}.hasOwnProperty.call(options.validators, key)) { + validators[key] = options.validators[key]; + } } - }); + } } app.component("VueFormGenerator", component); }; From 2994a75f2cf906a981cc4fc53d1d3bbc314fbbfb Mon Sep 17 00:00:00 2001 From: Andrea Martella <52160332+Andream98@users.noreply.github.com> Date: Fri, 10 May 2024 09:50:01 +0200 Subject: [PATCH 2/3] Update validators.js --- src/utils/validators.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/validators.js b/src/utils/validators.js index 2bf150e9..7afcb908 100644 --- a/src/utils/validators.js +++ b/src/utils/validators.js @@ -112,7 +112,6 @@ const validators = { }, string(value, field, model, messages = resources) { - console.log('validate string', field); let res = checkEmpty(value, field.required, messages); if (res != null) return res; From 5cea74786363694079825530698e865ba566a8c9 Mon Sep 17 00:00:00 2001 From: Andrea Martella <52160332+Andream98@users.noreply.github.com> Date: Tue, 14 May 2024 12:25:14 +0200 Subject: [PATCH 3/3] Update schema.js --- src/utils/schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/schema.js b/src/utils/schema.js index 0672d93d..13ea388e 100644 --- a/src/utils/schema.js +++ b/src/utils/schema.js @@ -76,7 +76,7 @@ const slugifyFormID = (schema, prefix = "") => { // Multiple dashes to one .replace(/-{2,}/g, "-") // Remove leading & trailing dashes - .replace(/^[-]++|[-]++$/g, "") + .replace(/^-+|-+$/g, "") // Remove anything that isn't a (English/ASCII) letter, number or dash. .replace(/([^a-zA-Z0-9-]+)/g, "") ); @@ -97,7 +97,7 @@ const slugify = (name = "") => { // Multiple dashes to one .replace(/-{2,}/g, "-") // Remove leading & trailing dashes - .replace(/^[-]++|[-]++$/g, "") + .replace(/^-+|-+$/g, "") // Remove anything that isn't a (English/ASCII) letter, number or dash. .replace(/([^a-zA-Z0-9-_/./:]+)/g, "") );