fix: register request validation

This commit is contained in:
Derrick Hammer 2023-06-11 02:04:36 -04:00
parent c0df04d7d5
commit c197b1425b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 3 deletions

View File

@ -7,9 +7,10 @@ import (
) )
type RegisterRequest struct { type RegisterRequest struct {
Email string `json:"email"` validatable validators.ValidatableImpl
Password string `json:"password"` Email string `json:"email"`
Pubkey string `json:"pubkey"` Password string `json:"password"`
Pubkey string `json:"pubkey"`
} }
func (r RegisterRequest) Validate() error { func (r RegisterRequest) Validate() error {
@ -19,3 +20,6 @@ func (r RegisterRequest) Validate() error {
validation.Field(&r.Password, validation.When(len(r.Pubkey) == 0, validation.Required)), validation.Field(&r.Password, validation.When(len(r.Pubkey) == 0, validation.Required)),
) )
} }
func (r RegisterRequest) Import(d map[string]interface{}) (validators.Validatable, error) {
return r.validatable.Import(d, r)
}