package com.apobates.forum.thrones.controller.form;

import com.apobates.forum.thrones.controller.helper.FieldMatch;
import com.apobates.forum.utils.Commons;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 *
 * @author xiaofanku
 * @since 20200516
 */
@FieldMatch(first="pswdConfirm", second="newPswd", message="{FieldMatch.registeForm.pswdConfirm}")
public class RegisteForm extends ActionForm {
    @NotBlank(message="{NotBlank.registeForm.names}")
    @Size(min=5, max=20, message="{Size.registeForm.names}")
    @Pattern(regexp = "^[A-Za-z0-9]+$", message="{Pattern.registeForm.names}")
    private String names;
    private String nickname;
    @NotBlank(message="{NotBlank.registeForm.newPswd}")
    @Size(min=6, max=100, message="{Size.registeForm.newPswd}")
    private String newPswd;
    @NotBlank(message="{NotBlank.registeForm.pswdConfirm}")
    @Size(min=6, max=100, message="{Size.registeForm.pswdConfirm}")
    private String pswdConfirm;
    
    public String getNames() {
        return Commons.isNotBlank(names) ? names.trim() : "";
    }
    
    public void setNames(String names) {
        this.names = names;
    }
    
    public String getNickname() {
        return nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    public String getNewPswd() {
        return Commons.isNotBlank(newPswd) ? newPswd.trim() : "";
    }
    
    public void setNewPswd(String newPswd) {
        this.newPswd = newPswd;
    }
    
    public String getPswdConfirm() {
        return Commons.isNotBlank(pswdConfirm) ? pswdConfirm.trim() : "";
    }
    
    public void setPswdConfirm(String pswdConfirm) {
        this.pswdConfirm = pswdConfirm;
    }
}