Ok. Everyone's got an answer on how to add validation rules to a ui-component field via XML. Unfortunately, I can't find anyone that seems to know how to implement a rule that requires a parameter or two. I'm sure the knowledge is out there, but nobody's asked the question. So here it is.
I'm looking to implement the min-words
validation rule for a textarea. I've got something like this:
<field name="text_area">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
...
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
<item name="min-words" xsi:type="array">
<item name="length" xsi:type="number">10</item>
</item>
</item>
...
</item>
</argument>
</field>
but I'm guessing, and this doesn't quite work. I'm close, but can't figure out what the "length" parameter is really supposed to be, and looking at the rules.js
file doesn't provide any clues.