diff --git a/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js b/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js index 27582b936..95bdb9095 100644 --- a/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js +++ b/webroot/config/networking/routeaggregate/ui/js/models/routeAggregateModel.js @@ -72,6 +72,12 @@ define([ ctwu.getPermissionsValidation() ]; + validations.push({ + key : "routes", + type : cowc.OBJECT_TYPE_COLLECTION, + getValidation : "rtAggregateRoutesValidation" + }); + if (this.isDeepValid(validations)) { attr = this.model().attributes; newRouteAggregateData = $.extend(true, {}, attr); diff --git a/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js b/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js index 6a62a9a6d..5384c152f 100644 --- a/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js +++ b/webroot/config/networking/routeaggregate/ui/js/models/rtAggregateRoutesModel.js @@ -23,6 +23,19 @@ define([ attrErrorObj[attr + cowc.ERROR_SUFFIX_ID] = (isValid == true) ? false : isValid; errors.set(attrErrorObj); + }, + + validations: { + rtAggregateRoutesValidation: { + route: function(value, attr, finalObj) { + var route = getValueByJsonPath(finalObj, "route", ""), + routeArry = route.split("/"); + if(routeArry.length !== 2 || (!isIPv4(routeArry[0]) && + !isIPv6(routeArry[0]))) { + return "Enter valid IPv4 or IPv6 Prefix"; + } + } + } } }); diff --git a/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js b/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js index 40b46894e..7435e546f 100644 --- a/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js +++ b/webroot/config/networking/routeaggregate/ui/js/views/routeAggregateEditView.js @@ -59,7 +59,7 @@ define([ false); Knockback.applyBindings(self.model, document.getElementById(modalId)); - kbValidation.bind(self); + kbValidation.bind(self, {collection:self.model.model().attributes.routes}); //permissions ctwu.bindPermissionsValidation(self); }, null, true @@ -138,14 +138,16 @@ define([ viewConfig: { path: "routes", collection: "routes", + validation: + "rtAggregateRoutesValidation", templateId: cowc.TMP_EDITABLE_GRID_ACTION_VIEW, columns: [{ elementId: "route", - name: "Routes", + name: "Route Prefix", view: "FormInputView", width: 350, viewConfig: { - placeholder: "Enter Route", + placeholder: "xxx.xxx.xxx.xxx/xx", width: 350, path: "route", templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,