package com.uca.data_validation;


import java.util.regex.Pattern;


public final class StringValidator {

  private static final Pattern nameRegex  = Pattern.compile("^[A-Za-z\\x{00C0}-\\x{00FF}][A-Za-z\\x{00C0}-\\x{00FF}'\\-]+([ A-Za-z\\x{00C0}-\\x{00FF}][A-Za-z\\x{00C0}-\\x{00FF}'\\-]+)*");
  private static final Pattern emailRegex = Pattern.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", Pattern.CASE_INSENSITIVE);


  public static boolean isNameValid(String name) {
    return name != null && nameRegex.matcher(name).matches();
  }


  public static boolean isEmailValid(String email) {
    return email != null && emailRegex.matcher(email).matches();
  }


  public static boolean isAddressValid(String address) {
    return address != null && !address.isBlank();
  }

}
