refactor: rename checkPubkey to CheckPubkeyValidator

This commit is contained in:
Derrick Hammer 2023-06-06 23:27:43 -04:00
parent 9bacd95c9d
commit dd8e5704c8
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ type RegisterRequest struct {
Pubkey string `json:"pubkey"`
}
func checkPubkey(value interface{}) error {
func CheckPubkeyValidator(value interface{}) error {
p, _ := value.(string)
pubkeyBytes, err := hex.DecodeString(p)
if err != nil {
@ -44,7 +44,7 @@ func checkPubkey(value interface{}) error {
func (r RegisterRequest) Validate() error {
return validation.ValidateStruct(&r,
validation.Field(&r.Email, validation.Required, is.EmailFormat),
validation.Field(&r.Pubkey, validation.When(len(r.Password) == 0, validation.Required, validation.By(checkPubkey))),
validation.Field(&r.Pubkey, validation.When(len(r.Password) == 0, validation.Required, validation.By(CheckPubkeyValidator))),
validation.Field(&r.Password, validation.When(len(r.Pubkey) == 0, validation.Required)),
)
}