From 94aa8f2e2614cc2994253c9dd3bb5b455c1eb684 Mon Sep 17 00:00:00 2001 From: "Jason.Chuah" Date: Mon, 26 Jun 2023 22:06:32 +0800 Subject: [PATCH 1/2] issue#90: email validation does not work --- src/js/brutusin-json-forms.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/brutusin-json-forms.js b/src/js/brutusin-json-forms.js index 49ee5ea..da64efa 100644 --- a/src/js/brutusin-json-forms.js +++ b/src/js/brutusin-json-forms.js @@ -277,6 +277,14 @@ if (typeof brutusin === "undefined") { return BrutusinForms.messages["maxLength"].format(s.maxLength); } } + //Issue#90 + //Add a default regex pattern matching for email validation, or else user could use + //the `pattern` field for their own custom regex pattern + if (!s.pattern && s.format === "email") { + if (!value.match(/[^@\s]+@[^@\s]+\.[^@\s]+/)) { + return BrutusinForms.messages["email"]; + } + } } if (value !== null && !isNaN(value)) { if (s.multipleOf && value % s.multipleOf !== 0) { From 3b6356032916070b2ba2a288913d9ef97bdbc916 Mon Sep 17 00:00:00 2001 From: "Jason.Chuah" Date: Mon, 26 Jun 2023 22:56:42 +0800 Subject: [PATCH 2/2] issue#119: add support custom class name --- src/js/brutusin-json-forms.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/brutusin-json-forms.js b/src/js/brutusin-json-forms.js index da64efa..fc33945 100644 --- a/src/js/brutusin-json-forms.js +++ b/src/js/brutusin-json-forms.js @@ -329,6 +329,9 @@ if (typeof brutusin === "undefined") { input.title = s.description; input.placeholder = s.description; } + if (s.class) { + input.className = s.class; + } // if (s.pattern) { // input.pattern = s.pattern; // } @@ -395,6 +398,9 @@ if (typeof brutusin === "undefined") { }; input.schema = schemaId; input.id = getInputId(); + if (s.class) { + input.className = s.class; + } inputCounter++; if (s.description) { input.title = s.description;