From 7c3793760f0b74840cf7bb19b385a927677b56fd Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Tue, 18 Apr 2023 09:58:07 +0100 Subject: [PATCH] [POO] created email validation method --- 1ano/2semestre/poo/src/utils/Validations.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/1ano/2semestre/poo/src/utils/Validations.java b/1ano/2semestre/poo/src/utils/Validations.java index 902d67c..c333fc3 100644 --- a/1ano/2semestre/poo/src/utils/Validations.java +++ b/1ano/2semestre/poo/src/utils/Validations.java @@ -3,6 +3,10 @@ package utils; import java.util.regex.Pattern; 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) { 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); }