Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CreditCardForm.prototype._validateCvv = function (value, options) {
var cvvSize, minLength;
options = options || {};
minLength = options.minLength;
if (this._fieldKeys.indexOf('number') === -1) { // CVV only
return validator.cvv(value, minLength || [3, 4]);
}
cvvSize = this.get('possibleCardTypes').map(function (item) {
return item.code.size;
});
cvvSize = uniq(cvvSize);
return validator.cvv(value, cvvSize);
};
CreditCardForm.prototype._validateCvv = function (value, options) {
var cvvSize, minLength;
options = options || {};
minLength = options.minLength;
if (this._fieldKeys.indexOf('number') === -1) { // CVV only
return validator.cvv(value, minLength || [3, 4]);
}
cvvSize = this.get('possibleCardTypes').map(function (item) {
return item.code.size;
});
cvvSize = uniq(cvvSize);
return validator.cvv(value, cvvSize);
};
test(value) {
const { card } = number((this.parent as HostedInputValues).cardNumber);
return cvv(value, card && card.code ? card.code.size : undefined).isValid;
},
});
export const isCVV = (value) => valid.cvv(value).isValid;
export const isPostalCode = (value) => valid.postalCode(value, 4).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,
};
};
}