PHP 7.3 reaches end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in April 2022. We strongly recommend planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.

Form validation

The Magento application provides various ways to validate your form inputs. This implementation is based, and extends, jQuery Validation.

Validation Module Structure

There are three main validation modules present in Magento: jquery/validate, mage/validation, and mage/validation/validation.

jquery/validate

This is an alias for lib/web/jquery/jquery.validate. This is the base validation JavaScript file provided by jQuery that Magento extends.

mage/validation

This module is present at lib/web/mage/validation.js. This module includes jquery/validate and adds various functions, such as $.validator.addMethod, which can be used by mixins to add custom validation rules, a base set of rules to validate, the mage.validation widget, and more.

mage/validation/validation

This module is present at lib/web/mage/validation/validation.js. This is considered the entry point for the form validator in Magento and is aliased as validation at Magento_Theme/view/frontend/requirejs-config.js. This includes mage/validation (which in turn includes jquery/validate), and adds a few more rules to the validator.

See also