diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-10-14 19:19:50 +0300 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2013-10-14 19:49:57 +0300 |
commit | e55dc995617a19fbc5772d7bd9fb3082a2d2b1f4 (patch) | |
tree | 33ddd87a1e3f0976da2d0817bd09ebc2169c2d56 /acf2/model/field.lua | |
parent | d15bdd8d9177e0b74a5f7a675ad09ea15a04bc86 (diff) | |
download | aconf-e55dc995617a19fbc5772d7bd9fb3082a2d2b1f4.tar.bz2 aconf-e55dc995617a19fbc5772d7bd9fb3082a2d2b1f4.tar.xz |
persistence: boolean/string conversion
Diffstat (limited to 'acf2/model/field.lua')
-rw-r--r-- | acf2/model/field.lua | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/acf2/model/field.lua b/acf2/model/field.lua index 6cbfa96..5829201 100644 --- a/acf2/model/field.lua +++ b/acf2/model/field.lua @@ -17,11 +17,6 @@ local super = object.super local util = require('acf2.util') -local function contains(list, value) - for k, v in ipairs(list) do if v == value then return true end end - return false -end - M.Member = class() function M.Member:init(params) @@ -92,7 +87,9 @@ function M.Field:_validate(context, value) if self.required and value == nil then raise(context.path, 'Required value not set') end - if self.choice and value ~= nil and not contains(self.choice, value) then + if self.choice and value ~= nil and not util.contains( + self.choice, value + ) then raise(context.path, 'Invalid value') end if value ~= nil then self:validate(context, value) end |