githubEdit

Email

The email type provides validated email address storage with user and host extraction.

Overview

Property
Value

Go Type

som.Email / *som.Email

Database Schema

string / option<string> (with validation)

CBOR Encoding

Direct (as string)

Sortable

Yes

Definition

type User struct {
    som.Node

    PrimaryEmail   som.Email   // Required
    SecondaryEmail *som.Email  // Optional
}

Schema

Generated SurrealDB schema with email validation:

DEFINE FIELD primary_email ON user TYPE string
    ASSERT string::is::email($value);
DEFINE FIELD secondary_email ON user TYPE option<string>
    ASSERT $value == NONE OR $value == NULL OR string::is::email($value);

Creating Email Values

Filter Operations

Equality Operations

Set Membership

Comparison Operations

Component Extraction

Extract email parts:

String Operations on Components

After extracting email components, you can use string operations:

Nil Operations (Pointer Types Only)

Zero Value Check

Sorting

Method Chaining

Email filters support component extraction, which returns String filters for further chaining:

Common Patterns

Filter by Domain

Find Gmail Users

Find Admin Emails

Users with Secondary Email

Educational Institutions

Complete Example

Filter Reference Table

Base Operations

Operation
Description
Returns

Equal(val)

Exact match

Bool filter

NotEqual(val)

Not equal

Bool filter

In(vals...)

Value in set

Bool filter

NotIn(vals...)

Value not in set

Bool filter

Zero(bool)

Check empty

Bool filter

Truth()

To boolean

Bool filter

IsNil()

Is null (ptr only)

Bool filter

IsNotNil()

Not null (ptr only)

Bool filter

Component Extraction

Operation
Description
Returns

User()

Extract user part (before @)

String filter

Host()

Extract host part (after @)

String filter

After extraction, all String filter operations are available on the component.

Last updated