Zum Inhalt springen

Modul:Vorlage:stolpersteine-berlin.de

aus Wikipedia, der freien Enzyklopädie
Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch

Modul: Dokumentation

Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus


-- Modul:Vorlage:stolpersteine-berlin.de
-- Parametercheck [[Vorlage:stolpersteine-berlin.de]]
-- 2025-04-08



local faultID = function ( arg )
    local r = not  arg:match( "^[1-9]%d*$" )
    return r
end -- faultID()



local faultPfad = function ( arg )
    local s, s2 = arg:match( "^(.+)/(%l%l[%l%-]+%l%l)$" )
    if s then
        if s:find( "/", 5, true ) then
            s, s2 = s:match( "^(.+)/([1-9]%d*%-?%d*%l?)$" )
        end
        if s   and
           not ( s:match( "^%l%l[%l%d%-]+%l%l$" )  or 
                 s:match( "^%l%l[%l%d%-]+%l%l%-[1-9]%d*$" ) ) then
            s = false
        end
    end
    return  not s
end -- faultPfad()



-- Export
local p = { }

p.fault = function ( frame )
    local params = frame:getParent().args
    local sID    = params.ID
    local sPfad  = params.Pfad
    local r
    local s = mw.text.trim( frame.args[ 1 ]  or  "" )
    if sID == "" then
        sID = false
    end
    if sPfad == "" then
        sPfad = false
    end
    if sID then
        if faultID( sID ) then
            r = "ID"
        end
    end
    if sPfad then
        if faultPfad( sPfad ) then
            if r then
                r = "ID, Pfad"
            else
                r = "Pfad"
            end
        end
    end
    return r or ""
end -- p.fault

return p