예제 #1
0
파일: agent.go 프로젝트: 11101171/whale
func (a *Agent) ValidateInsert(v *revel.Validation) {
	v.Check(a.LoginPass,
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 30},
	).Key("agent.LoginPass").Message("登录密码大于1个字符小于30个字符")
	a.Validate(v)
}
예제 #2
0
파일: Role.go 프로젝트: qtzheng/SIMP
func (r *Role) Validate(v *revel.Validation) {
	v.Check(r.IsUse, revel.Required{})
	v.Check(r.ParentID, revel.MaxSize{50})
	v.Check(r.RoleCode, revel.Required{}, revel.MaxSize{50}, revel.MinSize{10})
	v.Check(r.RoleName, revel.Required{}, revel.MaxSize{10}, revel.MinSize{2})
	v.Check(r.Sort, revel.Required{})
}
func (e *Episode) Validate(v *revel.Validation) {
	v.Check(e.Name,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{255},
	)
}
예제 #4
0
파일: util.go 프로젝트: jango2015/OJ
func (p *Pagination) isValidPage(v *revel.Validation,
	bean interface{}, index ...int64) {
	n, err := engine.Count(bean)
	if err != nil {
		e := &revel.ValidationError{
			Message: "bean error",
			Key:     reflect.TypeOf(bean).Name(),
		}
		v.Errors = append(v.Errors, e)
	}
	//modify n to 0
	if n < 0 {
		n = 0
	}
	//current page number
	var c int64
	if len(index) == 0 {
		c = 1
	} else {
		c = index[0]
		if c == 0 {
			c = 1
		}
	}
	if c*perPage > n+perPage || c < 1 {
		e := &revel.ValidationError{
			Message: fmt.Sprintf("%d is out of range %d",
				c, n/perPage),
			Key: reflect.TypeOf(bean).Name(),
		}
		v.Errors = append(v.Errors, e)
	}
}
func (s *Series) Validate(v *revel.Validation) {
	v.Check(s.Name,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{255},
	)
}
예제 #6
0
파일: account.go 프로젝트: joho/firesize
func ValidatePassword(v *revel.Validation, password string) *revel.ValidationResult {
	return v.Check(password,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{5},
	)
}
예제 #7
0
func (requests Requests) Validate(v *revel.Validation) {
	v.Required(requests.User)
	v.Required(requests.RequestType)
	v.Required(requests.RequestCount)
	v.Required(requests.RequestTime)
	v.Required(requests.RequestPlace)
}
예제 #8
0
파일: document.go 프로젝트: oblank/mgorx
func (doc *Document) saveChain(v *revel.Validation) bool {
	if v != nil {
		doc.callCB("BeforeValidation")
		doc.Validate(v)
		if v.HasErrors() {
			return false
		}
		doc.callCB("AfterValidation")
	}
	doc.callCB("BeforeSave")
	if doc.IsNew() {
		doc.callCB("BeforeCreate")
	} else {
		doc.callCB("BeforeUpdate")
	}
	saved := doc.save()
	if doc.IsNew() {
		doc.callCB("AfterCreate")
	} else {
		doc.callCB("AfterUpdate")
	}
	doc.callCB("AfterSave")

	return saved
}
예제 #9
0
func (si SiteInfo) Validate(v *revel.Validation) {
	v.MaxSize(si.AboutUsTitle, 1024)

	v.Required(si.AboutUsTitle)
	v.Required(si.AboutUsContent)
	v.Required(si.TwitterURL)
	v.Required(si.FacebookURL)
}
예제 #10
0
func (u *UserMaillist) Validate(v *revel.Validation) {
	v.Required(u.Email).
		Message("Email required").
		Key("usermaillist.Email")
	v.Email(u.Email).
		Message("Valid email required").
		Key("usermaillist.Email")
}
예제 #11
0
파일: cmd.go 프로젝트: 11101171/whale
func (c *Cmd) ValidateUpdate(v *revel.Validation) {
	c.Validate(v)

	c.CmdId = strings.TrimSpace(c.CmdId)
	v.Check(c.CmdId,
		revel.Required{},
	).Key("cmd.CmdId").Message("CmdId不能为空")
}
예제 #12
0
func (self *Server) Validate(v *revel.Validation) {
	//	TODO: use it in controller
	v.Check(self.Label,
		revel.Required{},
		revel.MaxSize{63},
		revel.MinSize{1},
		revel.Match{userRegex},
	)
}
예제 #13
0
파일: account.go 프로젝트: joho/firesize
func (a *Account) Validate(v *revel.Validation) {
	v.Check(a.Email,
		revel.Required{},
		revel.MinSize{4},
		revel.Match{emailRegex},
	)

	ValidatePassword(v, a.Password).
		Key("account.Password")
}
예제 #14
0
파일: user.go 프로젝트: jango2015/OJ
func (user *User) Validate(v *revel.Validation) {
	v.Required(user.Name)
	v.Required(user.Email)
	valid := v.Email(user.Email)
	if user.Password != user.ConfirmPassword {
		v.Errors = append(v.Errors, &revel.ValidationError{Message: "两次密码不一致", Key: "user.Password"})
	}

	if user.HasName() {
		fmt.Println("has name")
		err := &revel.ValidationError{
			Message: "该用户名已经被注册",
			Key:     "user.Name",
		}
		v.Errors = append(v.Errors, err)
	}

	if valid.Ok {
		if user.HasEmail() {
			fmt.Println("has email")
			err := &revel.ValidationError{
				Message: "该邮箱已经被用于注册",
				Key:     "user.Email",
			}
			v.Errors = append(v.Errors, err)
		}
	}
}
예제 #15
0
func Validate(v *revel.Validation, user models.User) {
	v.Check(user.Username,
		revel.Required{},
		revel.MaxSize{18},
		revel.MinSize{2},
		revel.Match{userRegex},
	)

	validatePassword(v, user.Password).Key("user.Password")

}
예제 #16
0
func (tg *TaskGroup) Validate(v *revel.Validation) {
	tg.GroupName = strings.TrimSpace(tg.GroupName)
	tg.Description = strings.TrimSpace(tg.Description)

	v.Check(tg.GroupName,
		revel.Required{},
	).Key("taskGroup.GroupName").Message("组名不能为空")
	v.Check(tg.Description,
		revel.Required{},
	).Key("taskGroup.Description").Message("描述不能为空")
}
예제 #17
0
func (category Category) Validate(v *revel.Validation) {
	v.Required(category.Name).Message("请输入名称")

	if category.HasName() {
		err := &revel.ValidationError{
			Message: "名称已存在",
			Key:     "category.Name",
		}
		v.Errors = append(v.Errors, err)
	}
}
예제 #18
0
파일: cmd.go 프로젝트: 11101171/whale
func (c *Cmd) Validate(v *revel.Validation) {
	c.Shell = strings.TrimSpace(c.Shell)
	c.AgentId = strings.TrimSpace(c.AgentId)

	v.Check(c.AgentId,
		revel.Required{},
	).Key("cmd.AgentId").Message("AgentId不能为空")

	v.Check(c.Shell,
		revel.Required{},
	).Key("cmd.Shell").Message("脚本不能为空")
}
예제 #19
0
파일: message.go 프로젝트: science09/myapp
func (message *Message) Validate(v *revel.Validation) {
	v.Check(message.Email,
		revel.Required{},
		revel.MaxSize{50})
	v.Email(message.Email)
	v.Check(message.QQ, revel.MaxSize{20})
	v.Check(message.Url, revel.MaxSize{200})
	v.Check(message.Content,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{1000})
}
예제 #20
0
func (user *User) Validate(v *revel.Validation) {
	v.Check(user.Alias,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{4},
		revel.Match{userRegex},
	)

	v.Check(user.Name,
		revel.Required{},
		revel.MaxSize{100},
	)
}
예제 #21
0
파일: menu.go 프로젝트: JREAMLU/GoCMS
func (menu *Menu) Validate(v *revel.Validation) {
	v.Required(menu.Name).Message("请输入菜单名称!")
	v.MaxSize(menu.Name, 105).Message("最多35个字")
	v.Required(menu.Pid).Message("请选择父菜单!")
	v.Required(menu.Url).Message("请输入菜单地址!")
	v.Required(menu.Order).Message("请输入排序!")
}
예제 #22
0
func (u *Admin) Validate(v *revel.Validation) {
	v.Check(u.Username,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{4},
		revel.Match{userRegex},
	)

	v.Check(u.Password,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{5},
	)
}
예제 #23
0
파일: agent.go 프로젝트: 11101171/whale
func (a *Agent) Validate(v *revel.Validation) {
	a.Host = strings.TrimSpace(a.Host)
	a.Port = strings.TrimSpace(a.Port)
	a.LoginName = strings.TrimSpace(a.LoginName)
	a.LoginPass = strings.TrimSpace(a.LoginPass)
	a.InitShellCmd = strings.TrimSpace(a.InitShellCmd)
	a.Memo = strings.TrimSpace(a.Memo)

	v.Check(a.Host,
		revel.Required{},
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 100},
	).Key("agent.Host").Message("主机需要大于1字符小于100个字符")
	v.Check(a.Port,
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 4},
	).Key("agent.Port").Message("端口要大于1个字符小于4个字符")
	v.Check(a.LoginName,
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 30},
	).Key("agent.LoginName").Message("登录用户名大于1个字符小于30个字符")

	v.Check(a.Memo,
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 50},
	).Key("agent.Memo").Message("备注大于1个字符小于50个字符")
}
예제 #24
0
파일: admin.go 프로젝트: blackmady/GoCMS
//验证密码
func (P *Password) ValidatePassword(v *revel.Validation) {
	v.Required(P.Password).Message("请输入密码!")
	v.Required(P.PasswordConfirm).Message("请输入确认密码!")

	v.MinSize(P.Password, 6).Message("密码最少六位!")
	v.Required(P.Password == P.PasswordConfirm).Message("两次密码不相同!")
}
예제 #25
0
func (d *DataStream) Validate(v *revel.Validation) {
	v.Required(d.Name).Key("name").Message("Data stream name required")
	v.MinSize(d.Name, 3).Key("name").Message("Minimum length is 3 characters")
	v.Required(d.AccountId).Key("accountId").Message("Account ID required")
	v.Required(d.ProjectId).Key("projectId").Message("Project ID required")
	v.Required(d.DataStreamGroupId).Key("dataStreamGroupId").Message("Data Stream Group ID required")
}
예제 #26
0
파일: user.go 프로젝트: 11101171/whale
func (u *User) Validate(v *revel.Validation) {
	u.Username = strings.TrimSpace(u.Username)
	u.Password = strings.TrimSpace(u.Password)

	v.Check(u.Username,
		revel.Required{},
		revel.MinSize{Min: 4},
		revel.MaxSize{Max: 12},
	).Key("user.Username").Message("用户名需要大于4位小于12位")
	v.Check(u.Password,
		revel.Required{},
		revel.MinSize{Min: 6},
		revel.MaxSize{Max: 12},
	).Key("user.Password").Message("密码需要大于6位小于12位")
}
예제 #27
0
파일: user.go 프로젝트: vassilux/revor
func (user *User) Validate(v *revel.Validation) {
	v.Check(user.Username,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{4},
		revel.Match{userRegex},
	)

	ValidatePassword(v, user.Password).
		Key("user.Password")

	v.Check(user.Username,
		revel.Required{},
		revel.MaxSize{100},
	)
}
예제 #28
0
func (u *UserSignup) Validate(v *revel.Validation) {
	v.Required(u.Email).
		Message("Email required").
		Key("usersignup.Email")
	v.Email(u.Email).
		Message("Valid email required").
		Key("usersignup.Email")
	v.Required(u.Password).
		Message("Password required").
		Key("usersignup.Password")
	v.MinSize(u.Password, 8).
		Message("Password length must be at least 8").
		Key("usersignup.Password")
	v.Required(u.PasswordConfirm == u.Password).
		Message("The passwords do not match.").
		Key("usersignup.PasswordConfirm")
}
예제 #29
0
파일: server.go 프로젝트: 11101171/whale
func (server *Server) Validate(v *revel.Validation) {
	server.Theme = strings.TrimSpace(server.Theme)
	server.Content = strings.TrimSpace(server.Content)
	server.Content = strings.Replace(server.Content, " ", "", -1)
	server.Content = strings.Replace(server.Content, "\r\n", "", -1)

	v.Check(server.Theme,
		revel.Required{},
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 100},
	).Key("server.Theme").Message("主题需要大于1字符小于100个字符")
	v.Check(server.Content,
		revel.Required{},
		revel.MinSize{Min: 1},
		revel.MaxSize{Max: 30000},
	).Key("server.Content").Message("内容要大于1个字符小于50000个字符")
}
예제 #30
0
파일: base.go 프로젝트: 11101171/whale
func ValidationAddErr(v *revel.Validation, message string) {
	v.Errors = append(v.Errors,
		&revel.ValidationError{
			Message: message,
			Key:     "Err",
		},
	)
}