Module:Check DYK hook/sandbox explained

-- This module performs validation checks for hooks

local libraryUtil = require('libraryUtil')local p =

local validationPatternGroups =

function p._isValidHook(hook) -- Whether the given hook is valid. -- We use the patterns in the validationPatternGroups table to find whether -- a hook is valid or not. Hooks are treated as valid if they match at least -- one pattern from each group. libraryUtil.checkType("_isValidHook", 1, hook, "string") for _, patternGroup in ipairs(validationPatternGroups) do local found = false for _, pattern in ipairs(patternGroup) do if mw.ustring.find(hook, pattern) then found = true break end end if not found then return false end end return trueend

function p.isValidHook(frame) local args = frame.args local hook = args.hook or args[1] if not hook then error("No hook specified") end hook = hook:match('^%s*(.-)%s*$') -- Trim whitespace if p._isValidHook(hook) then return "yes" else return "" endend

return p