985
edits
No edit summary |
m (13 revisions imported) |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 51:
]]
local function check_isbn( isbn_str, error_string )
if nil ~= isbn_str:match("[^%s-0-9X]") then
return error_string;
end
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return
end
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then
return error_string;
return is_valid_isxn(isbn_str, 10) and '' or 'error';▼
end
else
local temp = 0;
if isbn_str:match( "^97[89]%d*$" ) == nil then
return error_string;
return is_valid_isxn_13 (isbn_str) and '' or 'error';▼
end
end
end
Line 78 ⟶ 84:
]]
local function check_ismn (id, error_string)
local text;
local valid_ismn = true;
Line 91 ⟶ 96:
end
return valid_ismn and '' or
end
Line 107 ⟶ 112:
]]
local function check_issn(id, error_string)
local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local text;
local valid_issn = true;
if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
return error_string;
end
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
Line 121 ⟶ 129:
end
return valid_issn and '' or
end
------------------------------< E N T R Y P O I N T S >--------------------------------------------------====
function p.check_isbn(frame)
return
end
function p.check_ismn(frame)
return
end
function p.check_issn(frame)
return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end
|