func ValidatePassword(v *revel.Validation, password string) *revel.ValidationResult { return v.Check(password, revel.Required{}, revel.MaxSize{15}, revel.MinSize{5}, ) }
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}, ) }
// TODO: Make an interface for Validate() and then validation can pass in the // key prefix ("booking.") func (booking Booking) Validate(v *revel.Validation) { v.Required(booking.User) v.Required(booking.Hotel) v.Required(booking.CheckInDate) v.Required(booking.CheckOutDate) v.Match(booking.CardNumber, regexp.MustCompile(`\d{16}`)). Message("Credit card number must be numeric and 16 digits") v.Check(booking.NameOnCard, revel.Required{}, revel.MinSize{3}, revel.MaxSize{70}, ) }
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.Name, revel.Required{}, revel.MaxSize{100}, ) }