By default, every field is a Loki Component with a ViewModel (ComponentViewModel
) and a repository (ComponentRepository
). If the ViewModel class is extending from \Yireo\@todo\AddressFieldViewModel
, you automatically get a basic validation for that field: If the field is required but the value is empty, then an error is added to the component - simple.
On top of this, each AddressFieldComponent
is able to use a validator array where each validator is implementing \Yireo\LokiCheckout\Validator\Component\AddressFieldValidatorInterface
. This array is empty by default, but you could easily just override this yourself.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Yireo\LokiCheckout\Component\Checkout\Address\Postcode">
<arguments>
<argument name="validators" xsi:type="array">
<item name="postcode" xsi:type="string">postcode</item>
</argument>
</arguments>
</type>
</config>
Coming soon