How to add a custom street validation of a shipping address?

I’m trying to add to the street input my own custom validation rule. In the checkout_index_index layout I’ve added the following item:

<item name="street" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="my-custom-validation-rule" xsi:type="string">true</item>
    </item>
</item>

But the rule is not loaded. I suppose that my item structure is wrong, as the html structure is different for street and other fields. What is the correct way to do this?

I have set up street to have only one line

I am also having same issue as my payment gateway allow only specific special character support so how to add a custom validation to street address

Obviously, if a custom payment gateway forbids some characters, you should remove these characters internally and automatically in the payment module instead on punish your shop’s customers with some odd restrictions.

Hello ! Please add code below:

<item name="street" xsi:type="array">
	<item name="children" xsi:type="array">
		<item name="0" xsi:type="array">
			<item name="validation" xsi:type="array">
				<item name="required-entry" xsi:type="boolean">true</item>
			</item>
		</item>
	</item>
</item>

Hope to help you ! :slight_smile:

1 Like