local scm = require 'Module:Sandbox/あめろ' local UrlWithPlaceholder = scm.String{pattern='^https?://.-%%s'} local NonEmptyString = scm.String{min_len=1} local SitesSchema = scm.Table{ [scm.Number{int=true}] = scm.Table{ name = NonEmptyString, icon = scm.Table{ file = NonEmptyString, size = NonEmptyString / nil, }, url = HttpUrl / scm.Function / scm.Table{validator=function(t) local Item = scm.Table{NonEmptyString, HttpUrl} local LastItem = scm.Table{NonEmptyString / nil, HttpUrl} for i = 1, #t - 1 do if not Item:test(t[i]) then return false end end return LastItem:test(t[#t]) end}, } } local p = {} function p.validate_data_sites() local sites = require('Module:IconLink/data').sites SitesSchema:assert(sites) return '格式正确' end return p