diff options
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 |