示例#1
0
func (language *Language) Validate(db *gorm.DB) {
	if language.Code == "invalid" {
		validations.AddErrorForColumn(db, language, "Code", "invalid language")
	}
}
示例#2
0
func (card *CreditCard) Validate(db *gorm.DB) {
	if !regexp.MustCompile("^(\\d){13,16}$").MatchString(card.Number) {
		validations.AddErrorForColumn(db, card, "Number", "invalid card number")
	}
}
示例#3
0
func (address *Address) Validate(db *gorm.DB) {
	if address.Address == "invalid" {
		validations.AddErrorForColumn(db, address, "Address", "invalid address")
	}
}
示例#4
0
func (user *User) Validate(db *gorm.DB) {
	if user.Name == "invalid" {
		validations.AddErrorForColumn(db, user, "Name", "invalid user name")
	}
}