Utils/time_validation.js
/**
 * 
 * @param {String} stg - The stg to be validated
 * @param {Number} min - The min value that a number can have within this group or number
 * @param {Number} max - The max value that a number can have within this group or number
 */
@param {String} stg - The stg to be validated
@param {Number} min - The min value that a number can have within this group or number
@param {Number} max - The max value that a number can have within this group or number
@param { String } stg - The stg to be validated @param { Number } min - The min value that a number can have within this group or number @param { Number } max - The max value that a number can have within this group or number
function isAValidRangeGroupOrNumber(stg, min, max) {
    if (stg == '*') {
        return true;
    } else if (stg.includes(',')) {
        let tokens = stg.split(',');
        return tokens.every(v => isAValidRangeGroupOrNumber(v, min, max));
    } else if (stg.includes('/')) {
        let tokens = stg.split('/');
        if (tokens.length !== 2) {
            return false;
        }
        let a = isAValidRangeGroupOrNumber(tokens[0], min, max);
        let isDigit = tokens[1].match(/^[0-9]+$/);
        let b = parseInt(tokens[1]);
        return isDigit != null && a && b >= min && b <= max;
    } else if (stg.includes('-')) {
        let tokens = stg.split('-');
        let isDigit1 = tokens[0].match(/^[0-9]+$/);
        let isDigit2 = tokens[1].match(/^[0-9]+$/);
        let a = parseInt(tokens[0]);
        let b = parseInt(tokens[1]);
        return isDigit1 != null && isDigit2 != null && a < b && a >= min && b <= max;
    }
    let isDigit = stg.match(/^[0-9]+$/);
    let num = parseInt(stg);
    return isDigit != null && num >= min && num <= max;
}
function isAValidRangeGroupOrNumber ( stg , min , max ) { if ( stg == '*' ) { return true ; } else if ( stg . includes ( ',' ) ) { let tokens = stg . split ( ',' ) ; return tokens . every ( v => isAValidRangeGroupOrNumber ( v , min , max ) ) ; } else if ( stg . includes ( '/' ) ) { let tokens = stg . split ( '/' ) ; if ( tokens . length !== 2 ) { return false ; } let a = isAValidRangeGroupOrNumber ( tokens [ 0 ] , min , max ) ; let isDigit = tokens [ 1 ] . match ( / ^[0-9]+$ / ) ; let b = parseInt ( tokens [ 1 ] ) ; return isDigit != null && a && b >= min && b <= max ; } else if ( stg . includes ( '-' ) ) { let tokens = stg . split ( '-' ) ; let isDigit1 = tokens [ 0 ] . match ( / ^[0-9]+$ / ) ; let isDigit2 = tokens [ 1 ] . match ( / ^[0-9]+$ / ) ; let a = parseInt ( tokens [ 0 ] ) ; let b = parseInt ( tokens [ 1 ] ) ; return isDigit1 != null && isDigit2 != null && a < b && a >= min && b <= max ; } let isDigit = stg . match ( / ^[0-9]+$ / ) ; let num = parseInt ( stg ) ; return isDigit != null && num >= min && num <= max ; }
@param {String} stg - The stg to be validated
 @param {Number} min - The min value that a number can have within this group or number
 @param {Number} max - The max value that a number can have within this group or number
@param { String } stg - The stg to be validated @param { Number } min - The min value that a number can have within this group or number @param { Number } max - The max value that a number can have within this group or number
// TODO: Rework this function to not be recursive