From c96de7204366fa7d3d7318d7b42f2bd3b34ac0ca Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 11 Sep 2019 12:28:58 +0200 Subject: [PATCH] luci-base: validation.js: implement length() datatype validator Signed-off-by: Jo-Philipp Wich --- .../luci-base/htdocs/luci-static/resources/validation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/luci-base/htdocs/luci-static/resources/validation.js b/modules/luci-base/htdocs/luci-static/resources/validation.js index ca544cb15d..79ae1d6707 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), -- 2.30.2