יחידה:ParamValidator: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
מ תקלדה
ניסוי, הצליח
שורה 106:
 
local options, n, more = {}
 
if frame.args['module_options'] then
local module_options = mw.loadData( frame.args['module_options'] )
if type( module_options ) ~= 'table' then return {} end
local title = frame:getTitlemw.title.getCurrentTitle()
options =return module_options[ title.namespace ] or module_options[ title.nsText ] or {}
if not next( options ) then return options end
end
שורה 134 ⟵ 132:
return res
end
,
table_empty = function( t ) -- normally, test if next(t) is nil, but for some perverse reason, non-empty tables returned by loadData return nil...
if not nexttype( optionst ) ~= 'table' then return optionstrue end
for a, b in pairs( t ) do return false end
return true
end
,
}
 
שורה 269 ⟵ 274:
return res
end
 
-- no option no work.
if nextutil.table_empty( options ) == nil then return '' end
 
-- get the errors.
local violations = calculateViolations( frame, options['doc-subpage'] )
 
-- special request of bora: use skip_empty_numeric
if violations['empty-undeclared-numeric'] then
שורה 289 ⟵ 293:
for pname in pairs( tab ) do if ignore( pname ) then tab[pname] = nil end end
-- prune empty violations
if nextutil.table_empty( tab ) == nil then violations[name] = nil end
-- WORK IS DONE. report the errors.
-- if report then count it.
שורה 297 ⟵ 301:
if offenders > 1 then report_params( 'multiple' ) end
if offenders ~= 0 then report_params( 'any' ) end -- could have tested for empty( report ), but since we count them anyway...
 
return wrap_report()
end