I have this plugin:
public function afterProcess(
LayoutProcessor $subject,
array $jsLayout
) {
...
if(isset(
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['vat_id']
)){
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['vat_id']
['validation']['validate-vat-id'] = 1; // this doesn't work !!!
// ['validation']['required-entry'] = 1; // this works!!!!
}
...
and this is my mixin:
var config = {
config: {
mixins: {
'Magento_SalesRule/js/view/payment/discount': {
'Vendor_Checkout/js/view/payment/discount': true
},
'mage/validation': {
'Vendor_Checkout/js/validation-vat-id-mixin': true
}
}
}
};
and this is my app/code/Vendor/Checkout/view/frontend/web/js/validation-vat-id-mixin.js
file:
define([
'jquery'
], function ($) {
"use strict";
return function () {
$.validator.addMethod(
'validate-vat-id',
function (value) {
console.log('hello custom validation');
// Some custom validation stuff here
return true;
},
$.mage.__('Your validation error message')
);
}
});
I'm not sure why this is not working :) . Can you give me some ideas what to try or to check ?
Thanks