Documentation
¶
Overview ¶
Package gormrules provides database-backed validation rules on top of gorm: exists and not_exists check a value against table columns.
Usage in a rule expression:
exists:table,column[,column...] the value exists in any column not_exists:table,column[,column...] the value exists in no column
Example: `validate:"required && not_exists:users,phone,email"`.
Register both on a validator with Register(v, db). Messages default to English; override them per validator with validator.WithMessages, e.g. {"exists": "{field} 不存在", "not_exists": "{field} 已存在"}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Exists ¶
type Exists struct {
// contains filtered or unexported fields
}
Exists validates that a value exists in one of the given table columns.
Click to show internal directories.
Click to hide internal directories.