feat: finish bilingual session auth learning lab
This commit is contained in:
@@ -15,13 +15,15 @@ public class ValidationAction extends ActionSupport {
|
||||
private String bio;
|
||||
private String scoreBand;
|
||||
private String submittedAt;
|
||||
private boolean seniorTrack;
|
||||
|
||||
@Override
|
||||
public String execute() {
|
||||
username = normalize(username);
|
||||
email = normalize(email);
|
||||
bio = normalize(bio);
|
||||
scoreBand = age >= 30 ? "Mid-career operator profile" : "Early-career operator profile";
|
||||
seniorTrack = age >= 30;
|
||||
scoreBand = seniorTrack ? "mid" : "early";
|
||||
submittedAt = LocalDateTime.now().format(TIME_FORMATTER);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -29,16 +31,16 @@ public class ValidationAction extends ActionSupport {
|
||||
@Override
|
||||
public void validate() {
|
||||
if (username == null || username.trim().length() < 3 || username.trim().length() > 20) {
|
||||
addFieldError("username", "Username must be between 3 and 20 characters.");
|
||||
addFieldError("username", "用户名长度需在 3 到 20 之间。 / Username must be between 3 and 20 characters.");
|
||||
}
|
||||
if (email == null || !email.contains("@") || email.indexOf('@') == email.length() - 1) {
|
||||
addFieldError("email", "Enter a valid email address.");
|
||||
addFieldError("email", "请输入有效邮箱。 / Enter a valid email address.");
|
||||
}
|
||||
if (age == null || age < 18 || age > 60) {
|
||||
addFieldError("age", "Age must be between 18 and 60.");
|
||||
addFieldError("age", "年龄需在 18 到 60 之间。 / Age must be between 18 and 60.");
|
||||
}
|
||||
if (bio != null && bio.trim().length() > 240) {
|
||||
addFieldError("bio", "Bio must stay under 240 characters.");
|
||||
addFieldError("bio", "简介不能超过 240 个字符。 / Bio must stay under 240 characters.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +87,8 @@ public class ValidationAction extends ActionSupport {
|
||||
public String getSubmittedAt() {
|
||||
return submittedAt;
|
||||
}
|
||||
|
||||
public boolean isSeniorTrack() {
|
||||
return seniorTrack;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user