I want to overwrite rules.js in my module.
Original location: vendor/module-ui/view/base/web/js/lib/validation/rules.js
I created vendor/module/view/base/requirejs-config.js
var config = { 'map': { '*': { 'ui/js/lib/validation/rules': 'BB_Checkout/js/lib/validation/rules' } }
I don't get an error but it also doesn't apply the validation rules. If i move the file to my theme it does work so the rules.js file is correct.
My rules.js file is in Vendor/Module/view/base/web/js/lib/validation.
I also added the validation rules to the checkout_index_index.xml
Any idea? I feel like the path may be wrong since the path's in module-ui seem to be a bit different then the rest because it also has it's own requirejs-config in vendor.
Also my checkout_index_index.xml is in Vendor/Module/view/frontend/layout/ so it's in frontend but the rules.js is in base, maybe that is part of the problem?
Solved! Go to Solution.
I ended up going with Damian's solution in a different topic:
My main problem was that i indeed needed to use 'Magento_Ui' in the requirejs and also needed to copy utils.js.
Please keep below code in your requirejs-config.js file,
var config = { 'map': { '*': { 'Magento_Ui/js/lib/validation/rules': 'BB_Checkout/js/lib/validation/rules' } }
Just clear cache and check.
I figured out that overwriting rules.js might not be the best way to add a custom validator. So i'm trying this now: https://community.magento.com/t5/Magento-2-x-Programming/Add-custom-validator-on-phonenumber-in-che...
Sadly I can find no way to close this topic.
I ended up going with Damian's solution in a different topic:
My main problem was that i indeed needed to use 'Magento_Ui' in the requirejs and also needed to copy utils.js.