diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-03 20:46:58 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-12-03 20:46:58 -0200 |
commit | 8728210e143bcde6c666319c715b1eb7b18467d7 (patch) | |
tree | 7fbd73cdfbdaa8cca0d7041ea2f3ba55697859bb | |
parent | 7b214dd7de60c9dbc5ceba8edbe50477ddfc5da2 (diff) | |
download | luarocks-8728210e143bcde6c666319c715b1eb7b18467d7.tar.gz luarocks-8728210e143bcde6c666319c715b1eb7b18467d7.tar.bz2 luarocks-8728210e143bcde6c666319c715b1eb7b18467d7.zip |
stricter type check of versions
-rw-r--r-- | src/luarocks/type_check.lua | 11 |
1 files changed, 10 insertions, 1 deletions
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" | |||
11 | rockspec_types = { | 11 | rockspec_types = { |
12 | rockspec_format = "string", | 12 | rockspec_format = "string", |
13 | MUST_package = "string", | 13 | MUST_package = "string", |
14 | MUST_version = "string", | 14 | MUST_version = "[%w.]+-[%d]+", |
15 | description = { | 15 | description = { |
16 | summary = "string", | 16 | summary = "string", |
17 | detailed = "string", | 17 | detailed = "string", |
@@ -168,6 +168,15 @@ local function type_check_item(name, item, expected, context) | |||
168 | if not tonumber(item) then | 168 | if not tonumber(item) then |
169 | return nil, "Type mismatch on field "..context..name..": expected a number" | 169 | return nil, "Type mismatch on field "..context..name..": expected a number" |
170 | end | 170 | end |
171 | elseif expected_type == "string" then | ||
172 | if not tostring(item) then | ||
173 | return nil, "Type mismatch on field "..context..name..": expected a value convertible to string" | ||
174 | end | ||
175 | if expected ~= "string" then | ||
176 | if not item:match("^"..expected.."$") then | ||
177 | return nil, "Type mismatch on field "..context..name..": invalid value "..item | ||
178 | end | ||
179 | end | ||
171 | elseif expected_type == "table" then | 180 | elseif expected_type == "table" then |
172 | if item_type ~= expected_type then | 181 | if item_type ~= expected_type then |
173 | return nil, "Type mismatch on field "..context..name..": expected a table" | 182 | return nil, "Type mismatch on field "..context..name..": expected a table" |