From 8728210e143bcde6c666319c715b1eb7b18467d7 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 3 Dec 2011 20:46:58 -0200 Subject: stricter type check of versions --- src/luarocks/type_check.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index fea25973..57340675 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua @@ -11,7 +11,7 @@ rockspec_format = "1.0" rockspec_types = { rockspec_format = "string", MUST_package = "string", - MUST_version = "string", + MUST_version = "[%w.]+-[%d]+", description = { summary = "string", detailed = "string", @@ -168,6 +168,15 @@ local function type_check_item(name, item, expected, context) if not tonumber(item) then return nil, "Type mismatch on field "..context..name..": expected a number" end + elseif expected_type == "string" then + if not tostring(item) then + return nil, "Type mismatch on field "..context..name..": expected a value convertible to string" + end + if expected ~= "string" then + if not item:match("^"..expected.."$") then + return nil, "Type mismatch on field "..context..name..": invalid value "..item + end + end elseif expected_type == "table" then if item_type ~= expected_type then return nil, "Type mismatch on field "..context..name..": expected a table" -- cgit v1.2.3-55-g6feb