Skip to content

Commit 0db3e20

Browse files
committed
Merge branch 'MAGETWO-64413' into MPI-bugfixes
2 parents d61a705 + 46854c1 commit 0db3e20

File tree

2 files changed

+36
-8
lines changed
  • app/code/Magento/Payment/view/base/web/js/model/credit-card-validation
  • dev/tests/js/jasmine/tests/app/code/Magento/Payment/base/js/model/credit-card-validation

2 files changed

+36
-8
lines changed

app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
} else {
2020
factory(jQuery);
2121
}
22-
}(function ($, cvvValidator, creditCardNumberValidator, expirationDateValidator, monthValidator, creditCardData) {
22+
}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
2323
'use strict';
2424

2525
$.each({
@@ -49,6 +49,7 @@
4949

5050
/**
5151
* Validate credit card number based on mod 10
52+
*
5253
* @param {*} number - credit card number
5354
* @return {Boolean}
5455
*/
@@ -60,8 +61,9 @@
6061
'validate-card-date': [
6162

6263
/**
63-
* Validate credit card number based on mod 10
64-
* @param {*} date - month
64+
* Validate credit card expiration month
65+
*
66+
* @param {String} date - month
6567
* @return {Boolean}
6668
*/
6769
function (date) {
@@ -72,8 +74,9 @@
7274
'validate-card-cvv': [
7375

7476
/**
75-
* Validate credit card number based on mod 10
76-
* @param {*} cvv - month
77+
* Validate cvv
78+
*
79+
* @param {String} cvv - card verification value
7780
* @return {Boolean}
7881
*/
7982
function (cvv) {
@@ -86,12 +89,13 @@
8689
'validate-card-year': [
8790

8891
/**
89-
* Validate credit card number based on mod 10
90-
* @param {*} date - month
92+
* Validate credit card expiration year
93+
*
94+
* @param {String} date - year
9195
* @return {Boolean}
9296
*/
9397
function (date) {
94-
return monthValidator(date).isValid;
98+
return yearValidator(date).isValid;
9599
},
96100
$.mage.__('Incorrect credit card expiration year.')
97101
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'jquery/validate',
9+
'Magento_Payment/js/model/credit-card-validation/validator'
10+
], function ($) {
11+
'use strict';
12+
13+
describe('Magento_Payment/js/model/credit-card-validation/validator', function () {
14+
15+
it('Check credit card expiration year validator.', function () {
16+
var year = new Date().getFullYear();
17+
18+
expect($.validator.methods['validate-card-year']('1234')).toBeFalsy();
19+
expect($.validator.methods['validate-card-year']('')).toBeFalsy();
20+
expect($.validator.methods['validate-card-year']((year - 1).toString())).toBeFalsy();
21+
expect($.validator.methods['validate-card-year']((year + 1).toString())).toBeTruthy();
22+
});
23+
});
24+
});

0 commit comments

Comments
 (0)