Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test: value => expirationDate(value).isValid,
});
export const isExpirationDate = (month, year) => valid.expirationDate({ month, year }).isValid;
validateValues = (formValues) => {
const numberValidation = valid.number(formValues.number);
const expiryValidation = valid.expirationDate(formValues.expiry);
const maxCVCLength = (numberValidation.card || FALLBACK_CARD).code.size;
const cvcValidation = valid.cvv(formValues.cvc, maxCVCLength);
const validationStatuses = pick({
number: toStatus(numberValidation),
expiry: toStatus(expiryValidation),
cvc: toStatus(cvcValidation),
name: !!formValues.name ? "valid" : "incomplete",
postalCode: this._validatePostalCode(formValues.postalCode),
}, this._displayedFields);
return {
valid: every(values(validationStatuses), status => status === "valid"),
status: validationStatuses,
};
};
function confirmAddCardClicked(event) {
var name = document.getElementById("full-name").value;
var expDate = document.getElementById("exp-date").value;
var expMonth = expDate.substring(5);
var expYear = expDate.substring(0, 4);
var number = document.getElementById("cc-number").value;
var validationResult = cardValidator.number(number);
var expDateValidation = cardValidator.expirationDate({ month: expMonth , year: expYear });
addCardConfirmed(name, number, expMonth, expYear);
$("#add-card-modal").modal("toggle");
}
function cardInfoUpdated(event) {
var name = document.getElementById("full-name").value;
var expDate = document.getElementById("exp-date").value;
var number = document.getElementById("cc-number").value;
var validationResult = cardValidator.number(number);
var expDateValidation = cardValidator.expirationDate({ month: expDate.substring(5) , year: expDate.substring(0, 4) });
var readyToSave = validationResult.isValid && expDateValidation.isValid && name.length > 0;
document.getElementById("add-card-confirm-button").disabled = !readyToSave;
var formattedNumber = formatCardNumber(number);
if (number !== formattedNumber) {
document.getElementById("cc-number").value = formattedNumber;
}
}
CreditCardForm.prototype._onSplitDateChange = function () {
var validationResult;
var month = this.get('expirationMonth.value');
var year = this.get('expirationYear.value');
var monthValidation = validator.expirationMonth(month);
var yearValidation = validator.expirationYear(year);
if (monthValidation.isValid && yearValidation.isValid) {
validationResult = validator.expirationDate(month + year);
this.set('expirationMonth.isValid', validationResult.isValid);
this.set('expirationMonth.isPotentiallyValid', validationResult.isPotentiallyValid);
this.set('expirationYear.isValid', validationResult.isValid);
this.set('expirationYear.isPotentiallyValid', validationResult.isPotentiallyValid);
} else {
this.set('expirationMonth.isValid', monthValidation.isValid);
this.set('expirationMonth.isPotentiallyValid', monthValidation.isPotentiallyValid);
this.set('expirationYear.isValid', yearValidation.isValid);
this.set('expirationYear.isPotentiallyValid', yearValidation.isPotentiallyValid);
}
};