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