[POO] created email validation method

This commit is contained in:
TiagoRG 2023-04-18 09:58:07 +01:00
parent 5ffea8034e
commit 7c3793760f
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,10 @@ package utils;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class Validations { public class Validations {
public static boolean validateEmail(String email) {
return Pattern.matches("^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$", email);
}
public static boolean validateVehiclePlate(String plate) { public static boolean validateVehiclePlate(String plate) {
return Pattern.matches("^[A-Z]{2}-\\d{2}-\\d{2}|\\d{2}-[A-Z]{2}-\\d{2}|\\d{2}-\\d{2}-[A-Z]{2}|[A-Z]{2}-\\d{2}-[A-Z]{2}|[A-Z]{2}-[A-Z]{2}-\\d{2}|\\d{2}-[A-Z]{2}-[A-Z]{2}$", plate); return Pattern.matches("^[A-Z]{2}-\\d{2}-\\d{2}|\\d{2}-[A-Z]{2}-\\d{2}|\\d{2}-\\d{2}-[A-Z]{2}|[A-Z]{2}-\\d{2}-[A-Z]{2}|[A-Z]{2}-[A-Z]{2}-\\d{2}|\\d{2}-[A-Z]{2}-[A-Z]{2}$", plate);
} }