<commit_before>/************************
 * Calendar Validation  *
 * By <NAME>
 * <EMAIL>
*************************/

/**
 * Check if is a valid Day
 * @param {day}
 * @type {Function}
 */
var isValidDay = (function(day) {
    try {
        if ( (day <= 31 && day >= 1) && day !== undefined) {
            return true;
        } else {
            throw "Error: Days can be between 1 and 31 days only!";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Check if is a valid Month
 * @param {month}
 * @type {Function}
 */
var isValidMonth = (function(month) {
    try {
        if (month <= 12 && month >= 1 && month !== undefined) {
            return true;
        } else {
            throw "Error: Month can be between 1 and 12 months only!";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Check if is a valid Year
 * @param {year}
 * @type {Function}
 */
var isValidYear = (function(year) {
    try {
        if (year.length === 4 && year !== undefined) {
            return true;
        } else {
            throw "Error: Year must be in YYYY format (eg. 1999)";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Validate the Date based on dd/mm/yyyy pattern
 * @param txtDate - The full date in string format
 * @returns {boolean}
 */
var checkDate = function(txtDate) {
    var currVal = txtDate;

    if(currVal === "") {
        return false;
    }Modal

    var DatePattern = /^(\d{1,2})([./-])(\d{1,2})([./-])(\d{1,4})$/;
    var calendarDate = currVal.match(DatePattern);

    var day   = calendarDate[1];
    var month = calendarDate[3];
    var year  = calendarDate[5];

    if (isValidDay(day) && isValidMonth(month) && isValidYear(year)) {
        return true;
    } else {
        return false;
    }
};

/**
 * SAMPLE USAGE
 */
$(function() {

    var startInput = $(".dateRangeStart"),
        endInput = $(".dateRangeEnd");

    startInput.on('blur', function() {
        var currentValue = $(this).val();
        if (checkDate(currentValue)) {
            $(this).val(currentValue);
        } else {
            $(this).val("");
        }
    });

    endInput.on('blur', function(e) {
        var currentValue = $(this).val();
        if (checkDate(currentValue)) {
            $(this).val(currentValue);
        } else {
            $(this).val("");
        }
    });
});<commit_msg>Added VD Namespace<commit_after>/************************
 * Calendar Validation  *
 * By <NAME>
 * <EMAIL>
*************************/


var VD = {}; // VD = Valid Date
/**
 * Check if is a valid Day
 * @param {day}
 * @type {Function}
 */
VD.isValidDay = (function(day) {
    try {
        if ( (day <= 31 && day >= 1) && day !== undefined) {
            return true;
        } else {
            throw "Error: Days can be between 1 and 31 days only!";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Check if is a valid Month
 * @param {month}
 * @type {Function}
 */
VD.isValidMonth = (function(month) {
    try {
        if (month <= 12 && month >= 1 && month !== undefined) {
            return true;
        } else {
            throw "Error: Month can be between 1 and 12 months only!";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Check if is a valid Year
 * @param {year}
 * @type {Function}
 */
VD.isValidYear = (function(year) {
    try {
        if (year.length === 4 && year !== undefined) {
            return true;
        } else {
            throw "Error: Year must be in YYYY format (eg. 1999)";
            return false;
        }
    } catch(e) {
        console.log(e);
    }
});

/**
 * Validate the Date based on dd/mm/yyyy pattern
 * @param txtDate - The full date in string format
 * @returns {boolean}
 */
VD.checkDate = function(txtDate) {
    var currVal = txtDate;

    if(currVal === "") {
        return false;
    }

    var DatePattern = /^(\d{1,2})([./-])(\d{1,2})([./-])(\d{1,4})$/;
    var calendarDate = currVal.match(DatePattern);

    var day   = calendarDate[1];
    var month = calendarDate[3];
    var year  = calendarDate[5];

    if (isValidDay(day) && isValidMonth(month) && isValidYear(year)) {
        return true;
    } else {
        return false;
    }
};

/**
 * SAMPLE USAGE
 */
$(function() {

    var startInput = $(".dateRangeStart"),
        endInput = $(".dateRangeEnd");

    startInput.on('blur', function() {
        var currentValue = $(this).val();
        if (VD.checkDate(currentValue)) {
            $(this).val(currentValue);
        } else {
            $(this).val("");
        }
    });

    endInput.on('blur', function(e) {
        var currentValue = $(this).val();
        if (VD.checkDate(currentValue)) {
            $(this).val(currentValue);
        } else {
            $(this).val("");
        }
    });
});
{'fraction_non_alphanumeric': 0.18685331710286063, 'fraction_numerical': 0.010549807263136538, 'mean_word_length': 1.9154346540508576, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6672090', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1541, 'n_words': 400}