mirror of
https://github.com/smyalygames/kahoot-challenge-2025.git
synced 2025-05-18 16:54:15 +02:00
feat: add email validator
This commit is contained in:
parent
ca250b3718
commit
c37111f7a5
17
src/EMail.java
Normal file
17
src/EMail.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class EMail {
|
||||||
|
/**
|
||||||
|
* Checks if the email is in a valid format
|
||||||
|
* @param email The email address being checked
|
||||||
|
* @return <code>true</code> if the email is correctly formatted, otherwise <code>false</code>
|
||||||
|
*/
|
||||||
|
public boolean validate(String email) {
|
||||||
|
// Set up regex for email format
|
||||||
|
String emailRegex = "[^@ \\t\\r\\n]+@[^@ \\t\\r\\n]+\\.[^@ \\t\\r\\n]+";
|
||||||
|
Pattern pattern = Pattern.compile(emailRegex);
|
||||||
|
|
||||||
|
// Checks and returns if the email matches the regex pattern
|
||||||
|
return pattern.matcher(email).matches();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user