valid = this.vstack[0].apply(this, this.vstack[1]);
if (valid !== true) {
- this.field.setAttribute('data-tooltip', _('Expecting: %s').format(this.error));
+ var message = _('Expecting: %s').format(this.error);
+ this.field.setAttribute('data-tooltip', message);
this.field.setAttribute('data-tooltip-style', 'error');
- this.field.dispatchEvent(new CustomEvent('validation-failure', { bubbles: true }));
+ this.field.dispatchEvent(new CustomEvent('validation-failure', {
+ bubbles: true,
+ detail: {
+ message: message
+ }
+ }));
return false;
}
this.assert(false, valid);
this.field.setAttribute('data-tooltip', valid);
this.field.setAttribute('data-tooltip-style', 'error');
- this.field.dispatchEvent(new CustomEvent('validation-failure', { bubbles: true }));
+ this.field.dispatchEvent(new CustomEvent('validation-failure', {
+ bubbles: true,
+ detail: {
+ message: valid
+ }
+ }));
return false;
}
return this.assert(this.apply('port'), _('valid port or port range (port1-port2)'));
},
- macaddr: function() {
- return this.assert(this.value.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null,
- _('valid MAC address'));
+ macaddr: function(multicast) {
+ var m = this.value.match(/^([a-fA-F0-9]{2}):([a-fA-F0-9]{2}:){4}[a-fA-F0-9]{2}$/);
+ return this.assert(m != null && !(+m[1] & 1) == !multicast,
+ multicast ? _('valid multicast MAC address') : _('valid MAC address'));
},
host: function(ipv4only) {
string: function() {
return true;
+ },
+
+ directory: function() {
+ return true;
+ },
+
+ file: function() {
+ return true;
+ },
+
+ device: function() {
+ return true;
}
}
});