I'm trying to have a custom validation to one of my Magento 2 form fields that is generated via ui-components.
I know that I can make the value required by adding a validation
item in the config.
Like this:
<field name="title">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Some label here</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">whatever</item>
<item name="sortOrder" xsi:type="number">999</item>
<item name="dataScope" xsi:type="string">whatever</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item><!-- this validates it as required -->
</item>
</item>
</argument>
</field>
What do I need to add inside the validation
item and where do I place the js code that should validate my field based on custom conditions?
For example I want it to match a certain regex.