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
- blocks
-
CHARTJS-42 Use number fields and lists of values for the parameters of the chartjs and tableToChartJS macros
-
- Open
-
-
JWPLAYER-29 Use number fields for the width and height of the JW Player macro
-
- Open
-
-
XWIKI-25497 Use a number field for the number of events of the notifications macro
-
- Open
-
-
XWIKI-25498 Use number fields and a list of page properties for the parameters of the page list and tree macros
-
- Open
-
-
XWIKI-25499 Use number fields and lists of values for the parameters of the attachment picker macros
-
- Open
-
-
XWIKI-25580 Report the invalid values of the documents, documentTree and tree macros instead of an empty result
-
- Open
-
-
XWIKI-25581 Report the invalid values of the attachmentGalleryPicker and attachmentSelector macros instead of showing nothing
-
- Open
-
- is related to
-
XCOMMONS-3847 Invalid boolean and number values of a bean property are silently converted instead of failing
-
- Open
-
-
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
-
-
XWIKI-25287 The Edit Macro dialog doesn't enforce the constraints declared on the parameters of Java macros
-
- Open
-