Email Address Field Type
Description:
The email_address
field type is used to capture email addresses from users with built-in email validation. It ensures that email data is captured in a consistent format and validated according to email standards. This field type is essential for contact information, user registration, and communication features within your application.
Elasticsearch Mapping: keyword
(indexed)
YAML Definition
- name: contact_email
type: email_address
display_name: "Email Address"
guidance: "Enter a valid email address."
required: true
readonly: false
hidden: false
default_value: ""
validation: ""
validation_message: ""
Attributes
-
name (string): Required.
The unique identifier for the field. -
type (string): Required.
Must be set toemail_address
for email address fields. -
display_name (string): Optional.
The label displayed in the user interface. If not provided, a formatted version ofname
is used. -
guidance (string): Optional.
Help text or instructions for the field, assisting users in understanding what email address to enter. -
required (boolean): Optional.
Iftrue
, the field must be filled before submission. Default:false
. -
readonly (boolean): Optional.
Iftrue
, the field is read-only and cannot be edited by the user. Default:false
. -
hidden (boolean): Optional.
Iftrue
, the field is hidden from the user interface. Default:false
. -
default_value (string): Optional.
The default email address displayed when the form is first loaded. -
validation (string): Optional.
Custom email validation rule to override the default email validation. -
validation_message (string): Optional.
Custom validation error message to display when validation fails.
Examples
Basic Email Field:
- name: contact_email
type: email_address
display_name: "Email Address"
guidance: "Enter your primary email address"
required: true
Email with Custom Validation:
- name: work_email
type: email_address
display_name: "Work Email"
guidance: "Enter your work email address"
validation: "^[a-zA-Z0-9._%+-]+@company\\.com$"
validation_message: "Please enter a valid company email address"
required: true
Optional Email Field:
- name: secondary_email
type: email_address
display_name: "Secondary Email"
guidance: "Optional: Enter a secondary email address"
required: false
default_value: ""
Readonly Email Field:
- name: verified_email
type: email_address
display_name: "Verified Email"
readonly: true
default_value: "user@example.com"
Usage Notes
- Built-in Validation:
- The
email_address
field type includes automatic email format validation. - Validates that the input follows standard email format (user@domain.com).
- Checks for proper domain structure and valid characters.
- The
- Custom Validation:
- Use the
validation
attribute to override default email validation. - Useful for domain-specific email requirements (e.g., company emails only).
- Can use regex patterns for complex validation rules.
- Use the
- Validation Messages:
- Use
validation_message
to provide custom error messages. - Helpful for providing specific guidance on email requirements.
- Should be clear and actionable for users.
- Use
- Default Values:
- Use
default_value
to pre-fill the field with a default email address. - Common for pre-populating with user’s existing email or placeholder text.
- Use
- Required Fields:
- Set
required: true
for essential email addresses like primary contact emails. - Useful for user registration, account creation, or critical communication.
- Set
- Readonly Fields:
- Use
readonly
for verified or system-managed email addresses. - Common for displaying confirmed email addresses that shouldn’t be changed.
- Use
- Use Cases:
- User Registration: Primary email for account creation.
- Contact Information: Customer contact details, support requests.
- Communication: Newsletter subscriptions, notifications, alerts.
- Account Management: Email verification, password reset.
- Business Processes: Client contact information, stakeholder communications.
- Data Format:
- Email addresses are stored in lowercase for consistency.
- Special characters and international domains are supported.
- Maximum length typically follows email standards (254 characters).
- Security Considerations:
- Email addresses are sensitive personal information.
- Ensure proper data protection and privacy compliance.
- Consider encryption for storage if required by regulations.
- User Experience:
- Provide clear guidance on what email address to enter.
- Use appropriate labels (e.g., “Work Email”, “Personal Email”).
- Consider providing examples for complex email requirements.
- Accessibility:
- Ensure that email fields are keyboard accessible.
- Provide clear labels that screen readers can interpret.
- Include helpful error messages for validation failures.
By incorporating the email_address
field type into your schema, you ensure reliable and validated capture of email addresses, which is essential for user communication and account management within your application.