Is there any way to extend validation/rules.js in custom module (not theme) with a new validation rule without overriding the original rules.js?


This is the best way to add a new rule without override the file rules.js and use on LayoutProcessor.php or jsLayout.

    ],function ($,validator) {
    "use strict";
    return validator.addRule('validade-name-of-validation',
        function (value) {
            return /* your function */
        }, $.mage.__('Your error message.')


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.