34 lines
772 B
Go
34 lines
772 B
Go
package form
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
type EditorForm struct {
|
|
Name string
|
|
Content string
|
|
}
|
|
|
|
//func (f *HomepageForm) Validate() error {
|
|
// if f.Password != f.Confirm {
|
|
// return errors.New("password doesn't match confirmation")
|
|
// }
|
|
// if len(f.Username) < 3 {
|
|
// return errors.New("username needs to be at least 3 characters")
|
|
// }
|
|
// match, _ := regexp.MatchString("^[a-z0-9-_]+$", f.Username)
|
|
// if !match {
|
|
// return errors.New("only lowercase letters and digits are accepted for username")
|
|
// }
|
|
// if len(f.Password) < 6 {
|
|
// return errors.New("password needs to be at least 6 characters")
|
|
// }
|
|
// return nil
|
|
//}
|
|
|
|
func NewEditorForm(r *http.Request) *EditorForm {
|
|
return &EditorForm{
|
|
Name: r.FormValue("name"),
|
|
Content: r.FormValue("content"),
|
|
}
|
|
}
|