Details
-
Improvement
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
Unknown
-
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.
Attachments
Issue Links
- is related to
-
XWIKI-23045 Allow to define a provider of values for a macro parameter
-
- Open
-
-
XWIKI-25182 Numeric macro parameters accept any text in the Edit Macro dialog
-
- Open
-