Page MenuHomePhabricator

Proposal for more sophisticated "required" parameter option
Open, Needs TriagePublic

Description

I have been wondering whether it would be possible to add support in TemplateData for a more versatile required/deprecated/suggested designation of parameters. A discussion has been started at https://en.wikipedia.org/wiki/Wikipedia_talk:TemplateData#Add_support_for_more_sophisticated_%22required%22_options

There are many cases in which whether a parameter should be marked as required depends on whether certain other parameters are used or whether certain inputs are entered in those parameters. Likewise, the same can be said for deprecated parameters. Is this technically feasible?

Event Timeline

This seems like a duplicate of T192385: Support for conditional parameters in TemplateData, and others. Such tasks are technically feasible, but there is currently no active development taking place on TemplateData.

At least part of this seems doable, i.e. have something like this:

		"archive-url": {
			"label": "Archive URL",
			"description": "The URL of an archived copy of a web page, if or in case the URL becomes unavailable; requires 'archivedate'",
			"type": "line",
			"aliases": [
				"archiveurl"
			],
			"requires": [
				"archive-date"
			],
		},

The "requires" could be used for the dependency case, where using one parameter requires the use of another parameter.

But for the use case mentioned in the thread on en wiki, I'm not quite sure how that would be modelled. Specific examples might help conceptualise that.

Vvjjkkii renamed this task from Proposal for more sophisticated "required" parameter option to hpaaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
Mvolz renamed this task from hpaaaaaaaa to Proposal for more sophisticated "required" parameter option.Jul 1 2018, 8:57 AM
Mvolz lowered the priority of this task from High to Medium.
Mvolz updated the task description. (Show Details)
Mvolz lowered the priority of this task from Medium to Low.Jul 1 2018, 9:04 AM
CommunityTechBot raised the priority of this task from Low to Needs Triage.Jul 5 2018, 7:02 PM

I'm also interested in adding support for conditional required parameters. For example, Ukrainian Wikipedia has template «Шаблон:Ніхонґо» (https://uk.wikipedia.org/wiki/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:%D0%9D%D1%96%D1%85%D0%BE%D0%BD%D2%91%D0%BE), that has one required parameter, that either second positional parameter (|2=) or third positional parameter (|3=) or parameter hepburn (|hepburn=). If one of them is presented, then the template will work, but if none of them is presented, then it doesn't and throws an error. So, I need some features that will indicate to the user, that they need to enter one of the listed parameters, but not all of them.

I'm afraid what people are asking for here is called "programming" and requires an actual programming language. Which we have. Lua. The pretty much only thing that's missing is a good way to display such error messages as part of the VisualEditor experience. One possible solution is when each template comes with a separate tiny "parameter validator" Lua module that can be called individually by VisualEditor.