File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
src/main/java/org/spacehub Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1-
21package org .spacehub .entities ;
32
43import jakarta .persistence .Entity ;
@@ -91,4 +90,4 @@ public boolean isCredentialsNonExpired() {
9190 public boolean isEnabled () {
9291 return enabled ;
9392 }
94- }
93+ }
Original file line number Diff line number Diff line change 1+ package org .spacehub .security ;
2+
3+ import org .springframework .stereotype .Service ;
4+ import java .util .function .Predicate ;
5+ import java .util .regex .Pattern ;
6+
7+ @ Service
8+ public class EmailValidator implements Predicate <String > {
9+
10+ private static final String emailRegex =
11+ "^(?=.{1,64}@)[A-Za-z0-9_-]+(\\ .[A-Za-z0-9_-]+)*@" +
12+ "[^-][A-Za-z0-9-]+(\\ .[A-Za-z0-9-]+)*(\\ .[A-Za-z]{2,})$" ;
13+
14+ private static final Pattern pattern = Pattern .compile (emailRegex );
15+
16+ public boolean test (String email ) {
17+ if (email == null ) {
18+ return false ;
19+ }
20+ return pattern .matcher (email ).matches ();
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments