func (hotel *Hotel) Validate(v *revel.Validation) { v.Check(hotel.Name, revel.Required{}, revel.MaxSize{50}, ) v.MaxSize(hotel.Address, 100) v.Check(hotel.City, revel.Required{}, revel.MaxSize{40}, ) v.Check(hotel.State, revel.Required{}, revel.MaxSize{6}, revel.MinSize{2}, ) v.Check(hotel.Zip, revel.Required{}, revel.MaxSize{6}, revel.MinSize{5}, ) v.Check(hotel.Country, revel.Required{}, revel.MaxSize{40}, revel.MinSize{2}, ) }
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("请输入排序!") }
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) }
func (p *Problem) Validate(v *revel.Validation, in, out []byte) { v.Required(p.Title).Message("Title Required") v.Min(int(p.MemoryLimit), 1).Message("TimeLimit Required") v.Min(int(p.TimeLimit), 1).Message("MemoryLimit Required") v.Required(p.Description).Message("Description Required") v.Required(in).Message("input file needed") v.Required(out).Message("output file needed") v.MaxSize(p.InputSample, 512).Message("input sample too long") v.MaxSize(p.OutputSample, 512).Message("output sample too long") path := p.TestPath() p.InputTestPath = path + "/inputTest" p.OutputTestPath = path + "/outputTest" }
func ValidateUserPassword(v *revel.Validation, password string) *revel.ValidationResult { result := v.Required(password).Message("Password required") if !result.Ok { return result } result = v.MinSize(password, 6).Message("Password must be at least 6 characters") if !result.Ok { return result } result = v.MaxSize(password, 200).Message("Password must be at most 200 characters") return result }
func ValidatePostTitle(v *revel.Validation, title string) *revel.ValidationResult { result := v.Required(title).Message("A post must have a title") if !result.Ok { return result } result = v.MinSize(title, 3).Message("Post title must exceed 2 characters") if !result.Ok { return result } result = v.MaxSize(title, 200).Message("Post title cannot exceed 200 characters") return result }
func ValidateUserEmail(v *revel.Validation, email string) *revel.ValidationResult { result := v.Required(email).Message("Email address required") if !result.Ok { return result } result = v.MinSize(email, 6).Message("Email address can not be less than 6 characters") if !result.Ok { return result } result = v.MaxSize(email, 200).Message("Email address can not exceed 200 characters") if !result.Ok { return result } result = v.Match(email, EmailRegex).Message("You must provide a valid email address") return result }
func ValidateProfileName(v *revel.Validation, name string) *revel.ValidationResult { result := v.Required(name).Message("Name required") if !result.Ok { return result } result = v.MinSize(name, 2).Message("Name must be at least 2 characters") if !result.Ok { return result } result = v.MaxSize(name, 100).Message("Name must be at most 100 characters") if !result.Ok { return result } // Inverse regexp matcher (name cannot contain reserved # or @ symbols) if invalidNameMatcher := NameRegex.FindString(name); invalidNameMatcher == "" { result = v.Error("Invalid Name. Reserved characters ('#' and '@') are not allowed") } return result }
func ValidateProfileUserName(v *revel.Validation, username string) *revel.ValidationResult { result := v.Required(username).Message("User name required") if !result.Ok { return result } result = v.MaxSize(username, 64).Message("User name can not exceed 64 characters") if !result.Ok { return result } result = v.Match(username, UserNameRegex).Message("Invalid User name. Alphanumerics allowed only") if !result.Ok { return result } // Inverse regexp matcher (username cannot be the same as any blacklisted usernames) if blacklistMatcher := UserNameBlacklistRegex.FindString(username); blacklistMatcher != "" { result = v.Error("Invalid User name. Reserved keywords not allowed") } return result }
func ValidateProfileDescription(v *revel.Validation, description string) *revel.ValidationResult { result := v.MaxSize(description, 400).Message("Profile description cannot exceed 400 characters") return result }
func ValidateProfileSummary(v *revel.Validation, summary string) *revel.ValidationResult { result := v.MaxSize(summary, 140).Message("Profile summary cannot exceed 140 characters") return result }
func ValidateProfilePhotoUrl(v *revel.Validation, photoUrl string) *revel.ValidationResult { result := v.MaxSize(photoUrl, 200).Message("Photo URL cannot exceed 200 characters") return result }
func (p Product) Validate(v revel.Validation) { v.Required(Id) v.Required(Code) v.MaxSize(Name, 10) }