mirror of
https://github.com/airlabspl/uptimemonitor.git
synced 2025-08-14 12:19:19 +02:00
initial commit
This commit is contained in:
31
form/setup_form.go
Normal file
31
form/setup_form.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package form
|
||||
|
||||
import "net/mail"
|
||||
|
||||
type SetupForm struct {
|
||||
Name string
|
||||
Email string
|
||||
Password string
|
||||
|
||||
Errors map[string]string
|
||||
}
|
||||
|
||||
func (f *SetupForm) Validate() bool {
|
||||
f.Errors = map[string]string{}
|
||||
|
||||
if f.Name == "" {
|
||||
f.Errors["Name"] = "The name is required"
|
||||
}
|
||||
|
||||
if f.Email == "" {
|
||||
f.Errors["Email"] = "The email is required"
|
||||
} else if _, err := mail.ParseAddress(f.Email); err != nil {
|
||||
f.Errors["Email"] = "The email format is invalid"
|
||||
}
|
||||
|
||||
if f.Password == "" {
|
||||
f.Errors["Password"] = "The password is required"
|
||||
}
|
||||
|
||||
return len(f.Errors) == 0
|
||||
}
|
Reference in New Issue
Block a user