All files / app/utils validation.ts

86.36% Statements 19/22
50% Branches 2/4
66.66% Functions 2/3
81.25% Lines 13/16

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  84x 12x 84x 84x 121x 26x 26x   55x 12x 580x   92x             47x 47x    
// taken from backend
export const nameValidationPattern =
  /^(?!\p{Zs})[\p{L}\p{M}\p{Zs}\p{Pi}\p{Pf}\p{Pd},.'"·・&/|]+(?<!\p{Zs})$/u;
export const nameMinLength = 2;
export const nameMaxLength = 100;
export const usernameValidationPattern = /^[a-z][0-9a-z_]*[a-z0-9]$/i;
export const validatePassword = (password: string) => {
  return password.length >= 8 && password.length < 256;
};
export const emailValidationPattern =
  /^[0-9a-z]([0-9a-z\-_+]|(\.[0-9a-z\-_+]))*@([0-9a-z-]+\.)*[0-9a-z-]+\.[a-z]{2,}$/i;
export const timePattern = /\d{2}:\d{2}/;
 
export const profileAboutMeMinLength = 150;
 
export function validatePastDate(stringDate: string) {
  const date = new Date(stringDate);
  return !isNaN(date.getTime()) && date < new Date();
}
 
export function lowercaseAndTrimField(name: string) {
  return name.trim().toLowerCase();
}