How do I check the CPF from the LayoutProcessor class by the 'validation' attribute in Magento 2

0

I am changing a module in Magento 2 and need to add a cpf validation in the vat_id field. Using the Magento-SystemCode_BrazilCustomerAttributes module as a basis

In my plugin class I have the following method:

  public function afterProcess(
    \Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
    array  $jsLayout
) {


    $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
    ['shippingAddress']['children']['shipping-address-fieldset']['children']['vat_id'] = [
        'component' => 'Magento_Ui/js/form/element/abstract',
        'label' => __('VAT number'),
        'config' => [
            'customScope' => 'shippingAddress',
            'template' => 'ui/form/field',
            'elementTmpl' => 'ui/form/element/input',
            'id' => 'vat_id',
        ],
        'validation' => [
            'required-entry' => true,
        ],
        'visible' => true,
        'provider' => 'checkoutProvider',
        'dataScope' => 'shippingAddress.vat_id',
        'sortOrder' => 140,
        'id' => 'vat_id',
    ];


    return $jsLayout;
}

You can insert a function that verifies that what was typed in the vat_id field is a cpf valid from the

'validation' => [
            'required-entry' => true,
        ],
    
asked by anonymous 31.10.2018 / 15:16

0 answers