-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable account locale resolving and add account preference
- Loading branch information
Showing
20 changed files
with
344 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
server/src/main/java/io/myfinbox/account/domain/AccountDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.myfinbox.account.domain; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.io.Serializable; | ||
|
||
import static io.myfinbox.shared.Guards.doesNotOverflow; | ||
import static lombok.AccessLevel.PACKAGE; | ||
|
||
@ToString | ||
@Embeddable | ||
@EqualsAndHashCode | ||
@NoArgsConstructor(access = PACKAGE, force = true) | ||
public final class AccountDetails implements Serializable { | ||
|
||
public static final int MAX_LENGTH = 255; | ||
|
||
private String firstName; | ||
private String lastName; | ||
|
||
public AccountDetails(String firstName, String lastName) { | ||
if (!StringUtils.isBlank(firstName)) { | ||
this.firstName = doesNotOverflow(firstName.trim(), MAX_LENGTH, "firstName overflow, max length allowed '%d'".formatted(MAX_LENGTH)); | ||
} | ||
|
||
if (!StringUtils.isBlank(lastName)) { | ||
this.lastName = doesNotOverflow(lastName.trim(), MAX_LENGTH, "lastName overflow, max length allowed '%d'".formatted(MAX_LENGTH)); | ||
} | ||
} | ||
|
||
public String firstName() { | ||
return firstName; | ||
} | ||
|
||
public String lastName() { | ||
return lastName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
server/src/main/java/io/myfinbox/account/domain/EmailAddress.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.myfinbox.account.domain; | ||
|
||
import jakarta.persistence.Embeddable; | ||
|
||
import java.io.Serializable; | ||
import java.util.regex.Pattern; | ||
|
||
import static io.myfinbox.shared.Guards.*; | ||
|
||
@Embeddable | ||
public record EmailAddress(String emailAddress) implements Serializable { | ||
|
||
static final String patternRFC5322 = "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$"; | ||
static final Pattern pattern = Pattern.compile(patternRFC5322); | ||
static final int MAX_LENGTH = 255; | ||
|
||
public EmailAddress { | ||
notBlank(emailAddress, "emailAddress cannot be blank"); | ||
doesNotOverflow(emailAddress.trim(), MAX_LENGTH, "emailAddress max length must be '%d'".formatted(MAX_LENGTH)); | ||
matches(emailAddress, pattern, "emailAddress must match '%s'".formatted(patternRFC5322)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return emailAddress; | ||
} | ||
} |
Oops, something went wrong.