luci-base: cbi.js: add client-side hexstring datatype validator
authorJo-Philipp Wich <jo@mein.io>
Mon, 5 Nov 2018 10:13:39 +0000 (11:13 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 5 Nov 2018 10:13:39 +0000 (11:13 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/cbi.js

index d9b9baf7be9f500c6209cd72a491d8ebaf1626b7..1c2b14df6985cc80996023604dae127e087d096b 100644 (file)
@@ -582,6 +582,11 @@ var CBIValidatorPrototype = {
                                return this.apply(subvalidator, undefined, subargs);
 
                        return this.assert(true);
+               },
+
+               hexstring: function() {
+                       return this.assert(this.value.match(/^([a-f0-9][a-f0-9]|[A-F0-9][A-F0-9])+$/),
+                               _('hexadecimal encoded value'));
                }
        }
 };