Skip to main content
The email field stores a single email address string and validates it against the standard email format. You can optionally restrict which domains are allowed or blocked.

Configuration options

[]string
List of domains that are NOT allowed. Email addresses from these domains will fail validation. Cannot be set if onlyDomains is specified.
[]string
List of domains that are exclusively allowed. Email addresses must be from one of these domains. Cannot be set if exceptDomains is specified.
bool
default:"false"
When true, requires the field value to be a non-empty, valid email address.

Validation rules

The email field validates:
  • Format: Value must be a valid email address format
  • Domain allowlist: If onlyDomains is set, email domain must be in the list
  • Domain blocklist: If exceptDomains is set, email domain must NOT be in the list
  • Required: If enabled, value cannot be empty
You cannot set both exceptDomains and onlyDomains at the same time. Choose one approach based on your use case.

Go examples

Database column type

Common use cases

Best practices

  • Use onlyDomains when you want to restrict to specific organizations or institutions
  • Use exceptDomains to block temporary/disposable email services
  • Email validation is case-insensitive for the domain part
  • Consider email verification workflows in addition to format validation
  • Store emails in lowercase for consistency in queries

Zero value

The zero value for email fields is an empty string "".