feat: user domain -- errors
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"backend/pkg/validate/national"
|
||||
"backend/pkg/validate/phone"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
LastName string
|
||||
PhoneNumber string
|
||||
Email string
|
||||
PubKey string
|
||||
NationalID string
|
||||
BirthDate time.Time // format YYYY-MM-DD in presentation
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (u *User) ValidatePhoneNumber(phoneNumber string) error {
|
||||
ok, err := phone.IsValid(phoneNumber)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *User) ValidateNationalID(ID string) error {
|
||||
ok, err := national.IsValid(ID)
|
||||
if !ok {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user