I have created a form using UI components. I am able to add min and max length field validation using the below code.
<field name="sku">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string">Primary Barcode</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">sku</item>
<item name="elementTmpl" xsi:type="string">Vendor_Module/form/element/input</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
<item name="min_text_length" xsi:type="number">13</item>
<item name="max_text_length" xsi:type="number">13</item>
</item>
</item>
</argument>
</field>
As you can see min and max length is the same for the field. I do not want is use min_text_length
and max_text_length
for this validation because it shows an error message like Please enter more or equal than 13 symbols.
. Instead, I want to use some validation that can give an error message specifying that the exact 13 characters are required for this field.
How to achieve it?