Modul:Check isxn: Unterschied zwischen den Versionen

test issn for correct format;
imported>The Earwig
K (Protected "Module:Check isxn": High-risk Lua module: thousands of mainspace transclusions ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)))
(test issn for correct format;)
Zeile 51: Zeile 51:
]]
]]


function check_isbn( isbn_str, error_string )
local function check_isbn( isbn_str, error_string )
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
Zeile 78: Zeile 78:
]]
]]


function check_ismn (id, error_string)
local function check_ismn (id, error_string)
local text;
local text;
local valid_ismn = true;
local valid_ismn = true;
Zeile 106: Zeile 106:
]]
]]


function check_issn(id, error_string)
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 issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local text;
local text;
local valid_issn = true;
local valid_issn = true;


if not id:match ('^%d%d%d%d%-%d%d%d%d$') then
return error_string;
end
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn


Zeile 121: Zeile 125:
return valid_issn and '' or error_string
return valid_issn and '' or error_string
end
end
------------------------------< E N T R Y  P O I N T S >--------------------------------------------------====


function p.check_isbn(frame)
function p.check_isbn(frame)