luci-app-firewall: use maxlength datatype instead of validate function
authorHannu Nyman <hannu.nyman@iki.fi>
Thu, 17 Sep 2015 07:45:53 +0000 (10:45 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Thu, 17 Sep 2015 08:02:13 +0000 (11:02 +0300)
Switch the zonename validation to use
a compound datatype "and(uciname,maxlength(14))"
instead of a separate 'validate' function.

Remove the unnecessary function that was introduced by 34e875b

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua

index 46b3744403087998a13ee65af7616c8be63b96d4..6c90476f817f797a8190c73436b68e18dadad466 100644 (file)
@@ -60,7 +60,7 @@ s:tab("advanced", translate("Advanced Settings"))
 name = s:taboption("general", Value, "name", translate("Name"))
 name.optional = false
 name.forcewrite = true
-name.datatype = "uciname"
+name.datatype = "and(uciname,maxlength(14))"
 
 function name.write(self, section, value)
        if zone:name() ~= value then
@@ -76,15 +76,6 @@ function name.write(self, section, value)
        }
 end
 
-function name.validate(self, value)
-       -- fw3 defines 14 as the maximum length of zone name
-       if #value > 14 then
-               return nil, translate("Zone name is too long")
-       else
-               return value
-       end
-end
-
 p = {
        s:taboption("general", ListValue, "input", translate("Input")),
        s:taboption("general", ListValue, "output", translate("Output")),