diff --git a/modules/luci-base/htdocs/luci-static/resources/validation.js b/modules/luci-base/htdocs/luci-static/resources/validation.js index d3208c9b79..5959338bf4 100644 --- a/modules/luci-base/htdocs/luci-static/resources/validation.js +++ b/modules/luci-base/htdocs/luci-static/resources/validation.js @@ -51,7 +51,7 @@ const Validator = baseclass.extend({ else return false; - if (value != null) + if (value != null && value != undefined) this.value = value; return func.apply(this, args); @@ -287,6 +287,24 @@ const ValidatorFactory = baseclass.extend({ nomask ? _('valid IPv6 address') : _('valid IPv6 address or prefix')); }, + ip6ll(nomask) { + /* fe80::/10 -> 0xfe80 .. 0xfebf */ + const x = parseInt(this.value, 16) | 0; + const isll = (((x & 0xffc0) ^ 0xfe80) === 0); + + return this.assert(isll && this.apply('ip6addr', nomask), + _('valid IPv6 Link Local address')); + }, + + ip6ula(nomask) { + /* fd00::/8 -> 0xfd00 .. 0xfdff */ + const x = parseInt(this.value, 16) | 0; + const isula = (((x & 0xfe00) ^ 0xfc00) === 0); + + return this.assert(isula && this.apply('ip6addr', nomask), + _('valid IPv6 ULA address')); + }, + ip4prefix() { return this.assert(!isNaN(this.value) && this.value >= 0 && this.value <= 32, _('valid IPv4 prefix value (0-32)'));