• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang revel.Validation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/revel/revel.Validation的典型用法代码示例。如果您正苦于以下问题:Golang Validation类的具体用法?Golang Validation怎么用?Golang Validation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Validation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ValidateInsert

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)
}
开发者ID:11101171,项目名称:whale,代码行数:7,代码来源:agent.go


示例2: Validate

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{})
}
开发者ID:qtzheng,项目名称:SIMP,代码行数:7,代码来源:Role.go


示例3: Validate

func (e *Episode) Validate(v *revel.Validation) {
	v.Check(e.Name,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{255},
	)
}
开发者ID:archeious,项目名称:ARES-Historical-NOT-IN-USE,代码行数:7,代码来源:episode.go


示例4: isValidPage

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)
	}
}
开发者ID:jango2015,项目名称:OJ,代码行数:33,代码来源:util.go


示例5: Validate

func (s *Series) Validate(v *revel.Validation) {
	v.Check(s.Name,
		revel.Required{},
		revel.MinSize{1},
		revel.MaxSize{255},
	)
}
开发者ID:archeious,项目名称:ARES-Historical-NOT-IN-USE,代码行数:7,代码来源:series.go


示例6: ValidatePassword

func ValidatePassword(v *revel.Validation, password string) *revel.ValidationResult {
	return v.Check(password,
		revel.Required{},
		revel.MaxSize{15},
		revel.MinSize{5},
	)
}
开发者ID:joho,项目名称:firesize,代码行数:7,代码来源:account.go


示例7: Validate

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)
}
开发者ID:canerdogan,项目名称:revel-orders,代码行数:7,代码来源:request.go


示例8: saveChain

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
}
开发者ID:oblank,项目名称:mgorx,代码行数:25,代码来源:document.go


示例9: Validate

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)
}
开发者ID:bertzzie,项目名称:obrolansubuh-models,代码行数:8,代码来源:siteinfo.go


示例10: Validate

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")
}
开发者ID:slnaing07,项目名称:revel-modz,代码行数:8,代码来源:user.go


示例11: ValidateUpdate

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不能为空")
}
开发者ID:11101171,项目名称:whale,代码行数:8,代码来源:cmd.go


示例12: Validate

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},
	)
}
开发者ID:digideskio,项目名称:watchdog_ui,代码行数:9,代码来源:server.go


示例13: Validate

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")
}
开发者ID:joho,项目名称:firesize,代码行数:10,代码来源:account.go


示例14: Validate

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)
		}
	}
}
开发者ID:jango2015,项目名称:OJ,代码行数:28,代码来源:user.go


示例15: Validate

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")

}
开发者ID:tayamahotate,项目名称:PJApp,代码行数:11,代码来源:register.go


示例16: Validate

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("描述不能为空")
}
开发者ID:11101171,项目名称:whale,代码行数:11,代码来源:t_task_group.go


示例17: Validate

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)
	}
}
开发者ID:nashtsai,项目名称:gorevel,代码行数:11,代码来源:category.go


示例18: Validate

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("脚本不能为空")
}
开发者ID:11101171,项目名称:whale,代码行数:12,代码来源:cmd.go


示例19: Validate

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})
}
开发者ID:science09,项目名称:myapp,代码行数:12,代码来源:message.go


示例20: Validate

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},
	)
}
开发者ID:canerdogan,项目名称:revel-orders,代码行数:13,代码来源:user.go



注:本文中的github.com/revel/revel.Validation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang client.Conn类代码示例发布时间:2022-05-28
下一篇:
Golang revel.Response类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap