util.ts 1.37 KB
Newer Older
Mark Stenglein's avatar
Mark Stenglein committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/**
 * Utility File
 *
 * @author Mark Stenglein <mark@stengle.in>
 */

/**
 * isAlpha checks to make sure that an input string consists ONLY of lower or
 * upper case letters.
 *
 * @since 0.1.0
 * @param input Input string to be tested
 * @returns boolean value of if it is only alpha
 */
Mark Stenglein's avatar
Mark Stenglein committed
15 16
export function isAlpha(input: string): boolean {
    return /^[a-zA-Z]+$/.test(input);
17
}
Mark Stenglein's avatar
Mark Stenglein committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

/**
 * Checks to see if the input string is a compliant iama-token
 *
 * Definition of iama-token from the spec:
 *
 *     iana-token = 1*(ALPHA / DIGIT / "-")
 *     ; iCalendar identifier registered with IANA
 *
 * @author Mark Stenglein <mark@stengle.in>
 * @since 0.1.0
 * @param input Input string to be tested
 * @returns boolean value of if it is a valid token
 */
export function isIamaToken(input: string): boolean {
    return /^[a-zA-Z0-9-]+$/.test(input);
}

/**
 * Checks to see if the input string is a compliant x-token
 *
 * Definition of x-name from the spec:
 *
 *     x-name = "X-" [vendorid "-"] 1*(ALPHA / DIGIT / "-")
 *     ; Reserved for experimental use.
 *
 *     vendorid = 3*(ALPHA / DIGIT)
 *     ; Vendor identification
 *
 * @author Mark Stenglein <mark@stengle.in>
 * @since 0.1.0
 * @param input Input string to be tested
 * @returns boolean value of if input is a valid experimental token
 *
 * TODO: Implement this!
 */
export function isXName(input: string): boolean {
    return true;
}