const MINIMUM_PASSWORD_LENGTH = 12;

function validatePassword(password) {
  if (typeof password !== "string" || password.length < MINIMUM_PASSWORD_LENGTH) {
    return "auth.passwordTooShort";
  }

  return null;
}

function requireValidPassword(password, ValidationError) {
  const error = validatePassword(password);
  if (error) {
    throw new ValidationError(error);
  }
}

module.exports = { MINIMUM_PASSWORD_LENGTH, requireValidPassword, validatePassword };
