Beego validation accepts invalid data
<p>I am trying to validate some forms using Beego validation, but it is not working at all: invalid data passes without errors.</p>

<p>This the relevant code, I don't know what is wrong. Can you point me at the mistake?</p>

<p><a href="https://github.com/dionyself/golang-cms/blob/master/models/form.go" rel="nofollow">https://github.com/dionyself/golang-cms/blob/master/models/form.go</a></p>

<pre><code>package models

import (
    "github.com/astaxie/beego"
    "github.com/astaxie/beego/validation"
)

type BaseForm struct {
    Errors map[string]string
}

func (form *BaseForm) Validate() bool {
    valid := validation.Validation{}
    b, err := valid.Valid(form)
    if err != nil {
        beego.Error(err)
    }
    if !b {
        for _, err := range valid.Errors {
            form.Errors[err.Key] = err.Message
            beego.Debug(err.Key, err.Message)
        }
    }
    return b
}

type RegisterForm struct {
    BaseForm
    Username   string `form:"username" valid:"Required; AlphaNumeric; MinSize(4); MaxSize(300)"`
    Password   string `form:"password" valid:"Required; MinSize(4); MaxSize(30)"`
    PasswordRe string `form:"passwordre" valid:"Required; MinSize(4); MaxSize(30)"`
}

func (form *RegisterForm) Valid(v *validation.Validation) {
    // Check if passwords of two times are same.
    if form.Password != form.PasswordRe {
        v.SetError("PasswordRe", "Passwords did not match")
        return
    }
}

type ArticleForm struct {
    BaseForm
    Id            int    `form:"-"`
    Title         string `form:"title" valid:"Required;MinSize(4);MaxSize(300)"`
    Category      int    `form:"category"`
    Content       string `form:"content" valid:"Required; MinSize(50); MaxSize(2000)"`
    TopicTags     string `form:"topic-tags" valid:"MinSize(4); MaxSize(300)"`
    TaggedUsers   string `form:"tagged-users" valid:"MinSize(4); MaxSize(300)"`
    AllowReviews  bool   `form:"allow-reviews" valid:"Required"`
    AllowComments bool   `form:"allow-comments" valid:"Required"`
    Errors        map[string]string
}

func (form *ArticleForm) Valid(v *validation.Validation) {
    if form.Category &gt;= 0 {
        v.SetError("Category", "Invalid category")
        return
    }
}
</code></pre>

<p>Some documentation:
<a href="http://beego.me/docs/mvc/controller/validation.md" rel="nofollow">http://beego.me/docs/mvc/controller/validation.md</a></p>

<p>This is the code that parses the form:</p>

<pre><code>func (this *ArticleController) Post() {
    form := models.ArticleForm{}
    Art := new(models.Article)
    if err := this.ParseForm(&amp;form); err != nil {
        this.Abort("401")
    } else {
        db := this.GetDB()
        if !form.Validate() {
            this.Data["form"] = form
            var cats []*models.Category
            db.QueryTable("category").All(&amp;cats)
            this.Data["Categories"] = cats
            this.ConfigPage("article-editor.html")
            for key, msg := range form.Errors {
                fmt.Println(key, msg)
            }
        } else {
            db.Insert(Art)
            this.Data["Article"] = Art
            this.ConfigPage("article.html")
        }
    }
}
</code></pre>

<p>Note: FormData is always accepted (even an empty form), form.Validate() is always returning 'true'... 0 errors on logs. </p>