All files validations.ts

90% Statements 9/10
60% Branches 3/5
100% Functions 4/4
90% Lines 9/10

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 31 32 33  8x       6x       2x 2x   2x     2x   2x               2x           6x  
export function isValidName(value: string): boolean {
  return /^[A-Za-zÀ-ÖØ-öø-ÿ\s'-]{2,}$/.test(value.trim());
}
 
export function isValidEmail(value: string): boolean {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.trim());
}
 
export function isAdult(birthDate: string): boolean {
  const today = new Date();
  const birth = new Date(birthDate);
 
  let age = today.getFullYear() - birth.getFullYear();
 
  const monthDifference =
    today.getMonth() - birth.getMonth();
 
  Iif (
    monthDifference < 0 ||
    (monthDifference === 0 &&
      today.getDate() < birth.getDate())
  ) {
    age--;
  }
 
  return age >= 18;
}
 
export function isValidFrenchPostalCode(
  postalCode: string
): boolean {
  return /^[0-9]{5}$/.test(postalCode);
}