Ejemplo n.º 1
0
func (form *CategoryAdminForm) Valid(v *validation.Validation) {
	qs := models.Categories()

	if models.CheckIsExist(qs, "Name", form.Name, form.Id) {
		v.SetError("Name", "admin.field_need_unique")
	}

	if models.CheckIsExist(qs, "Slug", form.Slug, form.Id) {
		v.SetError("Slug", "admin.field_need_unique")
	}
}
Ejemplo n.º 2
0
func (form *UserAdminForm) Valid(v *validation.Validation) {
	qs := models.Users()

	if models.CheckIsExist(qs, "UserName", form.UserName, form.Id) {
		v.SetError("UserName", "auth.username_already_taken")
	}

	if models.CheckIsExist(qs, "Email", form.Email, form.Id) {
		v.SetError("Email", "auth.email_already_taken")
	}

	if len(i18n.GetLangByIndex(form.Lang)) == 0 {
		v.SetError("Lang", "Can not be empty")
	}
}