This issue has been created
 
 
XWiki Platform / cid:jira-generated-image-avatar-bb4d2fd4-aeb6-4939-8f4f-f4604652078a XWIKI-25197 Open

Allow wiki macro parameters to declare a range or a format for their value

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-c9013641-cbe1-47fb-a6e3-ec804573763b Charpentier Lucas created this issue on 07/Oct/26 12:17
 
Summary: Allow wiki macro parameters to declare a range or a format for their value
Issue Type: cid:jira-generated-image-avatar-bb4d2fd4-aeb6-4939-8f4f-f4604652078a Improvement
Assignee: Unassigned
Components: Rendering - WikiMacro
Created: 07/Oct/26 12:17
Priority: cid:jira-generated-image-static-major-b570f66c-b089-4652-81a5-be2df0788dd1 Major
Reporter: Charpentier Lucas
Description:

Java macros can declare constraints on the value of a parameter with Bean Validation annotations, such as @Min, @Positive or @Pattern. XWiki.WikiMacroParameterClass has no equivalent, so a wiki macro can only check a value while it runs, and it usually falls back silently to a default instead of reporting the problem.

Examples from XWiki Standard wiki macros:

  • documentTree limit: a non-numeric value silently becomes 15, and a value above the query items limit makes the children request fail.
  • documents count and notifications count: invalid or negative values are accepted or ignored without any message.

Proposal

  • Add optional constraint properties to XWiki.WikiMacroParameterClass, for example a minimum, a maximum and a pattern.
  • Expose them in the parameter descriptor the same way as the constraints declared by Java macros, so that the editor can use them, see XWIKI-25182.
  • Check them when the macro parameters are populated, so that an invalid value gives a clear error naming the parameter, as for a Java macro.

Allowed values coming from a list are covered separately by XWIKI-23045.

Raised in https://forum.xwiki.org/t/brainstorming-usability-criteria-for-auditing-macros-in-the-wysiwyg-editor/18907/19