All files / src/utils Type.ts

85.71% Statements 6/7
100% Branches 2/2
100% Functions 6/6
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30      5x 5x       6x           5x       5x       4x              
export default class Type {
  static isUUID(str: string): boolean {
    const uidReg =
      /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
    return uidReg.test(str);
  }
 
  static isIsoDate(data: string): boolean {
    return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})?$/.test(
      data,
    );
  }
 
  static isString(a: unknown): a is string {
    return typeof a === 'string' && a.length > 0;
  }
 
  static isNumber(a: unknown): a is number {
    return typeof a === 'number';
  }
 
  static isBoolean(a: unknown): a is boolean {
    return typeof a === 'boolean';
  }
 
  static isObject(a: unknown): a is object {
    return typeof a === 'object';
  }
}