firewall: validate max length of zone name
[project/luci.git] / applications / luci-app-firewall / luasrc / model / cbi / firewall / zone-details.lua
index e5bcb34..46b3744 100644 (file)
@@ -1,17 +1,6 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2010-2011 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
+-- Copyright 2008 Steven Barth <steven@midlink.org>
+-- Copyright 2010-2011 Jo-Philipp Wich <jow@openwrt.org>
+-- Licensed to the public under the Apache License 2.0.
 
 local nw = require "luci.model.network"
 local fw = require "luci.model.firewall"
@@ -87,6 +76,15 @@ 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")),