How to use the card-validator.expirationDate function in card-validator

To help you get started, we’ve selected a few card-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProtonMail / react-components / containers / payments / cardValidator.js View on Github external
export const isExpirationDate = (month, year) => valid.expirationDate({ month, year }).isValid;
github sbycrosz / react-native-credit-card-input / src / CCFieldValidator.js View on Github external
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,
    };
  };
github madmath / payment-request-show / bobpay / public / pay / bundled-card-validator.js View on Github external
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");
}
github madmath / payment-request-show / bobpay / public / pay / bundled-card-validator.js View on Github external
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;
  }
}
github braintree / braintree-web / src / hosted-fields / internal / models / credit-card-form.js View on Github external
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);
  }
};

card-validator

A library for validating credit card fields

MIT
Latest version published 5 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages