Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ui-component-library / dist / forms / deps / isValidDates.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mobx_1 = require("xmobx/mobx");
const exotic_1 = require("exotic");
const isValidExpiryDate_1 = require("./isValidExpiryDate");
// time match hours, minutes, and seconds, 24-hour clock
const matchTimeString = /^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$/;
// dateString match m/d/yy and mm/dd/yyyy, allowing any combination of one or two digits for the day and month, and two or four digits for the year
const matchFullDate = /^(1[0-2]|0?[1-9])([\/-])(3[01]|[12][0-9]|0?[1-9])(?:\2)(?:[0-9]{2})?[0-9]{2}$/;
/**
 * @param {String | Date} value
 * @return {Boolean}
 */
// function isValidMonth(value) {
//   // .value == new Date().getFullYear()
//   const isBeforeOneMonthAhead = value < new Date().getMonth() + 1
//   // The credit card has expired. Choose a different expiration date.
//   if (isBeforeOneMonthAhead) {
//     return false
//   }
//   return true
// }
const dateContainer = mobx_1.observable({
    month: '',
    year: '',
});
/**
 * @see https://date-fns.org/
 *
 * @todo - use date_fns
 * @todo - use in the dateParse util
 * @todo - use in time atom
 */
// function isValidDate() {
//   //
// }
// @observer
// extends React.Component
class ExpiryDateValidation {
    constructor() {
        this.isValidMonth = (month) => {
            if (month && month > 0 && month <= 12) {
                return true;
            }
            else {
                return false;
            }
        };
        this.isValidYear = (year) => {
            if (year >= exotic_1.toNumber(isValidExpiryDate_1.currentYear)) {
                return true;
            }
            else {
                const expiryYearLength = year.length;
                let validYear = false;
                if (expiryYearLength >= 4) {
                    validYear = false;
                }
                else if (year >= exotic_1.toNumber(isValidExpiryDate_1.currentYearTwoDigit) &&
                    expiryYearLength === 2) {
                    validYear = true;
                }
                return validYear;
            }
        };
    }
    isValidTimeOrDay() {
        //
    }
}
const expiryDate = new ExpiryDateValidation();
exports.expiryDate = expiryDate;
const isValidMonth = expiryDate.isValidMonth;
exports.isValidMonth = isValidMonth;
const isValidYear = expiryDate.isValidYear;
exports.isValidYear = isValidYear;
//# sourceMappingURL=isValidDates.js.map