summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static/resources
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-11 12:28:58 +0200
committerJo-Philipp Wich <jo@mein.io>2019-09-11 12:28:58 +0200
commitc96de7204366fa7d3d7318d7b42f2bd3b34ac0ca (patch)
treed47e4001cd968e5b1a183c8bd01eb86c82f7726d /modules/luci-base/htdocs/luci-static/resources
parentf32f42bc259c2c24f4369e945123a1f06b33b0a3 (diff)
luci-base: validation.js: implement length() datatype validator
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/validation.js6
1 files changed, 6 insertions, 0 deletions
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),