26 lines
566 B
Go
26 lines
566 B
Go
package main
|
|
|
|
type Message struct {
|
|
Name string `json:"name"`
|
|
NameError string `json:"name_error"`
|
|
Phone string `json:"phone"`
|
|
PhoneError string `json:"phone_error"`
|
|
Email string `json:"email"`
|
|
Service string `json:"service"`
|
|
Note string `json:"note"`
|
|
VIN string `json:"vin"`
|
|
Errors int `json:"errors"`
|
|
}
|
|
|
|
func (m *Message) Validate() {
|
|
m.Errors = 0
|
|
if m.Name == "" {
|
|
m.NameError = "Jméno je povinné"
|
|
m.Errors += 1
|
|
}
|
|
if m.Phone == "" {
|
|
m.PhoneError = "Telefonní číslo je povinné"
|
|
m.Errors += 1
|
|
}
|
|
}
|