Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "minimum-length" option of the "validate-length" JS validation #4051

Merged
merged 1 commit into from
Aug 1, 2016

Conversation

adragus-inviqa
Copy link
Contributor

The minimum-length option was incorrectly used because the value had to be empty first in order to be checked, and that's illogical.

The `minimum-length` options was incorrectly used because the value _had to be empty_ first in order to be checked, and that's illogical.
@piotrekkaminski
Copy link
Contributor

Internal issue MAGETWO-53552

@mmansoor-magento mmansoor-magento merged commit 09a3d12 into magento:develop Aug 1, 2016
@adragus-inviqa adragus-inviqa deleted the patch-1 branch August 3, 2016 18:22
@PrajapatiChirag
Copy link

PrajapatiChirag commented Mar 16, 2017

we need to change lib/web/mage/validation.js

"validate-length": [
            function (v, elm) {
                var reMax = new RegExp(/^maximum-length-[0-9]+$/),
                    reMin = new RegExp(/^minimum-length-[0-9]+$/),
                    validator = this,
                    result = true,
                    length = 0;
                $.each(elm.className.split(' '), function (index, name) {
                    if (name.match(reMax) && result) {
                        length = name.split('-')[2];
/* Need to change message for maximum length validation*/
                        validator.attrLength = 'Maximum length of this field must be equal or less than '+ length +' symbols.';
                        result = (v.length <= length);
                    }
                    if (name.match(reMin) && result && !$.mage.isEmpty(v)) {
                        length = name.split('-')[2];
/* Need to change message for minimum length validation*/
                        validator.attrLength = 'Minimum length of this field must be equal or greater than '+ length +' symbols.';
                        result = v.length >= length;
                    }
                });
                return result;
            }, function () {
/* Need to change for displaying proper message */
                return $.mage.__("%1")
                    .replace('%1', this.attrLength);
            }
        ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants