From 442ef0bd3616c4335dc9ab04f59454e1e5632e4b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 16 Jul 2014 16:31:31 +0200 Subject: [PATCH] check_site_lib: add need_boolean check --- scripts/check_site_lib.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/check_site_lib.lua b/scripts/check_site_lib.lua index a2b5500b..ec2498ec 100644 --- a/scripts/check_site_lib.lua +++ b/scripts/check_site_lib.lua @@ -47,6 +47,18 @@ function need_number(varname, required) return var end +function need_boolean(varname, required) + local var = loadvar(varname) + + if required == false and var == nil then + return nil + end + + assert_type(var, 'boolean', "site.conf error: expected `" .. varname .. "' to be a boolean") + + return var +end + function need_array(varname, subcheck, required) local var = loadvar(varname)