From f8ff24d8bbd5bd8b187635f2efa1f98ea7695cf3 Mon Sep 17 00:00:00 2001 From: maria Date: Sat, 17 Oct 2015 14:20:04 +0200 Subject: [PATCH] Issue #14: add missing field validation (ipv4 fields) add validation for IPv4 fields. for now this is done with regex patterns. we may change to the ip npm package later. --- src/index.html | 124 +++++++++++++++++++++++++++++++---------- src/index.js | 5 ++ src/nls/locale-de.json | 7 ++- src/nls/locale-en.json | 7 ++- 4 files changed, 113 insertions(+), 30 deletions(-) diff --git a/src/index.html b/src/index.html index ec5dbf7..8355032 100644 --- a/src/index.html +++ b/src/index.html @@ -428,36 +428,67 @@

-
-
+
-
-
- -
- +
+
+ +
+ + +
+
+ .error.required +
- -
-
- -
- +
+
+
+ +
+ + + +
+
+ .error.required +
+
+ .error.ipPattern +
-
-
+ +
@@ -480,14 +511,32 @@

-
+
- + data-ng-model="wizard.ip.v4.lan" + data-ng-required="wizard.ip.meshLan && !state.ip.generate" + data-ng-pattern="{{ipPattern}}"> + + +
+
+ .error.required +
+
+ .error.ipPattern +
+
@@ -516,14 +565,33 @@

-
+
- + data-ng-model="wizard.ip.v4ClientSubnet" + data-ng-required="wizard.ip.distribute && !state.ip.register" + data-ng-pattern="{{ipPattern + '/(25|26|27|28)'}}"> + + +
+
+ .error.required +
+
+ .distribute.subnet.error.pattern +
+
diff --git a/src/index.js b/src/index.js index 776c19a..7b34d11 100644 --- a/src/index.js +++ b/src/index.js @@ -268,6 +268,11 @@ wizard.controller('WizardCtrl', [ }); }; + $scope.ipPattern = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + + '\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + + '\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + + '\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; + $scope.hasError = function(field) { var form = $scope.wizardForm; return (form.$submitted || form[field].$dirty) && form[field].$invalid; diff --git a/src/nls/locale-de.json b/src/nls/locale-de.json index 935b035..9b6f696 100644 --- a/src/nls/locale-de.json +++ b/src/nls/locale-de.json @@ -91,11 +91,16 @@ "label": "Client IP Addressen verteilen", "subnet": { "label": "Client IPv4 subnet", - "placeholder" :"" + "placeholder" :"", + "error.pattern": "Das ist keine gültige Subnet Adresse" }, "expectedClients": { "label":"Wieviele Benutzer erwartest du an deinem Freifunkknoten?" } + }, + "error": { + "required": "Dieses Feld wird benötigt, es sei denn du registrierst die IPs autmomatisch.", + "ipPattern": "Das ist keine gültige IP Adresse." } }, "advancedWifi": { diff --git a/src/nls/locale-en.json b/src/nls/locale-en.json index 271501a..ebac392 100644 --- a/src/nls/locale-en.json +++ b/src/nls/locale-en.json @@ -91,11 +91,16 @@ "label": "Distribute client IP addresses", "subnet": { "label": "Client IPv4 subnet", - "placeholder" :"" + "placeholder" :"", + "error.pattern":"This is not a valid subnet." }, "expectedClients": { "label":"Expected number of concurrent clients" } + }, + "error": { + "required": "This field is required unless you register new IPs automatically.", + "ipPattern": "This is not a valid IP adress." } }, "advancedWifi": {