From: Jo-Philipp Wich Date: Wed, 11 Sep 2019 10:28:58 +0000 (+0200) Subject: luci-base: validation.js: implement length() datatype validator X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c96de7204366fa7d3d7318d7b42f2bd3b34ac0ca;p=oweals%2Fluci.git luci-base: validation.js: implement length() datatype validator Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/validation.js b/modules/luci-base/htdocs/luci-static/resources/validation.js index ca544cb15..79ae1d670 100644 --- a/modules/luci-base/htdocs/luci-static/resources/validation.js +++ b/modules/luci-base/htdocs/luci-static/resources/validation.js @@ -419,6 +419,12 @@ var ValidatorFactory = L.Class.extend({ return this.assert(this.factory.parseDecimal(this.value) <= +max, _('value smaller or equal to %f').format(max)); }, + length: function(len) { + var val = '' + this.value; + return this.assert(val.length == +len, + _('value with %d characters').format(len)); + }, + rangelength: function(min, max) { var val = '' + this.value; return this.assert((val.length >= +min) && (val.length <= +max),