Added some notes on xosValidate
diff --git a/xos/core/xoslib/static/js/xosTenant.js b/xos/core/xoslib/static/js/xosTenant.js
index f933c89..24af63f 100644
--- a/xos/core/xoslib/static/js/xosTenant.js
+++ b/xos/core/xoslib/static/js/xosTenant.js
@@ -289,6 +289,9 @@
       'Create Slice': function() {

         var addDialog = this;

 

+        // TODO

+        // we should validate the slice with the custom xosValidate function defined in define_modle (xos-backbone.js:755)

+

         detailView.synchronous = true;

         detailView.afterSave = function() {

           $(addDialog).dialog('close');

diff --git a/xos/core/xoslib/static/js/xoslib/xos-backbone.js b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
index 6fb6cc1..38c23b8 100644
--- a/xos/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/xos/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -134,6 +134,16 @@
         xosValidate: function(attrs, options) {
             errors = {};
             foundErrors = false;
+            var self = this;
+
+            console.log(self);
+
+            // if(self.validators && self.validators.custom && typeof self.validators.custom === 'function'){
+            //     var error = self.validators.custom(attrs, options);
+            //     debugger;
+            //     console.log(error);
+            // }
+
             _.each(this.validators, function(validatorList, fieldName) {
                 _.each(validatorList, function(validator) {
                     if (fieldName in attrs) {
@@ -424,18 +434,25 @@
             modelAttrs.defaults = get_defaults(modelName);
         }
 
-//        if ((typeof xosdefaults !== "undefined") && xosdefaults[modelName]) {
-//            modelAttrs["defaults"] = xosdefaults[modelName];
-//        }
-
+        // NOTE
+        // if(modelName === 'slicePlus'){
+        //     debugger;
+        // }
         if ((typeof xosvalidators !== "undefined") && xosvalidators[modelName]) {
             modelAttrs["validators"] = $.extend({}, xosvalidators[modelName], attrs["validators"] || {});
-        } else if (attrs["validators"]) {
+        }
+        else if (attrs["validators"]) {
             modelAttrs["validators"] = attrs["validators"];
             console.log(attrs);
             console.log(modelAttrs);
         }
 
+        // NOTE this has been added by matteo to pass in custom validators
+        // will be evaluated by xosValidate on line 137
+        // if(typeof attrs.xosValidate === 'function' && attrs['validators']){
+        //     modelAttrs['validators'].custom = attrs.xosValidate;
+        // }
+
         lib[modelName] = XOSModel.extend(modelAttrs);
 
         collectionAttrs["model"] = lib[modelName];
@@ -735,8 +752,11 @@
                             defaults: extend_defaults("slice", {"network_ports": "", "site_allocation": []}),
                             validators: {"network_ports": ["portspec"]},
                             xosValidate: function(attrs, options) {
+                                // TODO this is not triggered
+                                // was it ment to override xosValidate in the XOS Model definition?
                                 errors = XOSModel.prototype.xosValidate.call(this, attrs, options);
                                 // validate that slice.name starts with site.login_base
+                                console.log('SlicePlus XOSValidate', attrs.site, this.site);
                                 site = attrs.site || this.site;
                                 if ((site!=undefined) && (attrs.name!=undefined)) {
                                     site = xos.sites.get(site);
diff --git a/xos/core/xoslib/static/js/xoslib/xosHelper.js b/xos/core/xoslib/static/js/xoslib/xosHelper.js
index cad242f..50be612 100644
--- a/xos/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/xos/core/xoslib/static/js/xoslib/xosHelper.js
@@ -573,7 +573,11 @@
                    model.save, we call it ourselves, so we can throw up our
                    validation error before creating the infoMsg in the log
                 */
+               
+                // NOTE
+                // this does NOT trigger the xosValidate function define in the model (eg: xos-backbone-js:755)
                 errors =  this.model.xosValidate(data);
+                console.log(this.model.xosValidate);
                 if (errors) {
                     this.onFormDataInvalid(errors);
                     return;