mirror of
https://github.com/openwrt/luci.git
synced 2026-04-15 19:01:56 +00:00
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 <newtwen+github@gmail.com>