gluon-web-model: remove unused field error message code

Validation errors are mostly handled in the frontend (by displaying
invalid fields with a red background). There was some code left in the
backend for handling different kinds of errors, and returning custom
error messages from validate(), but the resulting value was not used
anywhere.
This commit is contained in:
Matthias Schiffer 2020-05-08 22:24:43 +02:00 committed by Andreas Ziegler
parent 5adbaf2907
commit 45b518df11

View File

@ -186,6 +186,7 @@ function AbstractValue:__init__(...)
self.template = "model/valuewrapper" self.template = "model/valuewrapper"
self.error = false
self.state = M.FORM_NODATA self.state = M.FORM_NODATA
end end
@ -205,14 +206,9 @@ function AbstractValue:cfgvalue()
end end
end end
function AbstractValue:add_error(type, msg)
self.error = msg or type
self.state = M.FORM_INVALID
end
function AbstractValue:reset() function AbstractValue:reset()
self.error = nil
self.data = nil self.data = nil
self.error = false
self.state = M.FORM_NODATA self.state = M.FORM_NODATA
end end
@ -220,13 +216,9 @@ end
function AbstractValue:parse(http) function AbstractValue:parse(http)
self.data = self:formvalue(http) self.data = self:formvalue(http)
local ok, err = self:validate() if not self:validate() then
if not ok then self.error = true
if type(self.data) ~= "string" or #self.data > 0 then self.state = M.FORM_INVALID
self:add_error("invalid", err)
else
self:add_error("missing", err)
end
return return
end end