githubEdit

String

The string type is the most feature-rich type in SOM, with over 50 filter operations for pattern matching, transformation, and validation.

Overview

Property
Value

Go Type

string / *string

Database Schema

string / option<string>

CBOR Encoding

Direct

Sortable

Yes

Definition

type User struct {
    som.Node

    Name        string   // Required
    Bio         string   // Required
    Nickname    *string  // Optional (nullable)
}

Schema

Generated SurrealDB schema:

Filter Operations

Equality Operations

Set Membership

Comparison Operations

Substring Operations

Case Transformation

String Manipulation

String Parts

Length Operations

Validation Operations

These return boolean filters:

Encoding Operations

Nil Operations (Pointer Types Only)

Zero Value Check

Truth Conversion

Sorting

String fields with fulltext indexes support search operations:

Search is used with the query builder's Search() method:

See Full-Text Search for the complete guide.

Method Chaining

String filters support extensive chaining:

Complete Example

Filter Reference Table

Operation
Description
Returns

Equal(val)

Exact match

Bool filter

NotEqual(val)

Not equal

Bool filter

FuzzyMatch(pattern)

Pattern match with wildcards

Bool filter

FuzzyNotMatch(pattern)

Negated pattern match

Bool filter

In(vals...)

Value in set

Bool filter

NotIn(vals...)

Value not in set

Bool filter

LessThan(val)

Lexicographic <

Bool filter

LessThanEqual(val)

Lexicographic <=

Bool filter

GreaterThan(val)

Lexicographic >

Bool filter

GreaterThanEqual(val)

Lexicographic >=

Bool filter

Contains(sub)

Contains substring

Bool filter

StartsWith(prefix)

Starts with prefix

Bool filter

EndsWith(suffix)

Ends with suffix

Bool filter

Lowercase()

Convert to lowercase

String filter

Uppercase()

Convert to uppercase

String filter

Trim()

Remove whitespace

String filter

Reverse()

Reverse characters

String filter

Repeat(n)

Repeat n times

String filter

Replace(old, new)

Replace substring

String filter

Slug()

URL-friendly slug

String filter

Slice(start, len)

Substring

String filter

Split(sep)

Split to array

Slice filter

Words()

Split into words

Slice filter

Concat(val)

Append string

String filter

Join(sep)

Join array

String filter

Len()

String length

Numeric filter

IsEmail()

Validate email

Bool filter

IsURL()

Validate URL

Bool filter

IsDomain()

Validate domain

Bool filter

IsUUID()

Validate UUID

Bool filter

IsSemVer()

Validate semver

Bool filter

IsDateTime(fmt)

Validate datetime

Bool filter

IsIP()

Validate IP

Bool filter

IsIPv4()

Validate IPv4

Bool filter

IsIPv6()

Validate IPv6

Bool filter

IsLatitude()

Validate latitude

Bool filter

IsLongitude()

Validate longitude

Bool filter

IsAlpha()

Alphabetic only

Bool filter

IsAlphaNum()

Alphanumeric

Bool filter

IsAscii()

ASCII only

Bool filter

IsHexadecimal()

Hex string

Bool filter

IsNumeric()

Numeric string

Bool filter

Base64Decode()

Decode base64

String filter

Zero(bool)

Check empty

Bool filter

Truth()

To boolean

Bool filter

IsNil()

Is null (ptr)

Bool filter

IsNotNil()

Is not null (ptr)

Bool filter

Last updated