luci-base: add tuple validator
authorPaul Donald <redacted>
Sat, 14 Feb 2026 18:05:19 +0000 (19:05 +0100)
committerPaul Donald <redacted>
Mon, 16 Feb 2026 00:42:58 +0000 (01:42 +0100)
commitb6fc02d2810fa515398ec6e53c9d04bf835c1de4
tree15096d0f100e5e2eff22dad665ab987808fdd4d1
parent7ee6ba3dc26627be1af0a689a87f813d9d14a98d
luci-base: add tuple validator

There are a number of validation types which are useful
but inaccessible when a value field combines simple
data-types. Example <ipaddr><space><ipaddr>. At which point
one must write a custom validate function, and applying the
built-in factory methods is not trivial.

Introduce a tuple function which combines known types
to validate a string, with a single line definition.
E.g. an IP and a port space-separated:

opt.datatype = 'tuple(ipaddr,port)';

All validation methods must return true for valid data.

The tuple function splits on space by default, or any string
provided by sep(). Here, a comma:

opt.datatype = 'tuple(ipaddr,port,sep(","))';

After the string is separated, any error message displayed
corresponds to the first invalid part of the input string
encountered.

Signed-off-by: Paul Donald <redacted>
modules/luci-base/htdocs/luci-static/resources/validation.js
git clone https://git.99rst.org/PROJECT