Transformers

Transformers modify extracted token values — converting types, manipulating strings, or setting defaults. Apply them with the colon syntax: {Token:Transformer()}.

String Manipulation

TransformerArgumentsDescription
Trim()Removes leading and trailing whitespace
ToUpper()Converts to uppercase
ToLower()Converts to lowercase
TitleCase()Converts to title case
Remove('text')text to removeRemoves all occurrences of the specified text
RemoveStart('prefix')prefixRemoves the specified prefix
RemoveEnd('suffix')suffixRemoves the specified suffix
Replace('from','to')from, toReplaces all occurrences of one string with another
RegexReplace('pattern','replacement')regex, replacementReplaces regex matches (1s timeout)
Truncate(n)max lengthTruncates to the specified maximum length
Split('delimiter')delimiterSplits on delimiter, returns array
SubstringBefore('text')search stringExtracts text before first occurrence
SubstringAfter('text')search stringExtracts text after first occurrence
SubstringBeforeLast('text')search stringExtracts text before last occurrence
SubstringAfterLast('text')search stringExtracts text after last occurrence
Trim
C#
var template = "Value: {Name:Trim()}";
// Input: "Value:   Alice   " → Name = "Alice"
ToUpper / ToLower
C#
var template = "Code: {Code:ToUpper()}";
// Input: "Code: abc123" → Code = "ABC123"
TitleCase
C#
var template = "Name: {Name:TitleCase()}";
// Input: "Name: john doe" → Name = "John Doe"
Remove
C#
var template = "Value: {Value:Remove('$')}";
// Input: "Value: $42.00" → Value = "42.00"
RemoveStart
C#
var template = "Id: {Id:RemoveStart('ID-')}";
// Input: "Id: ID-12345" → Id = "12345"
RemoveEnd
C#
var template = "File: {File:RemoveEnd('.txt')}";
// Input: "File: readme.txt" → File = "readme"
Replace
C#
var template = "Tags: {Tags:Replace(',',' | ')}";
// Input: "Tags: red,green,blue" → Tags = "red | green | blue"
RegexReplace
C#
var template = "Phone: {Phone:RegexReplace('\\D','')}";
// Input: "Phone: (555) 867-5309" → Phone = "5558675309"
Truncate
C#
var template = "Bio: {Bio:Truncate(20)}";
// Input: "Bio: A very long biography text" → Bio = "A very long biograph"
Split
C#
var template = "Tags: {Tags:Split(',')}";
// Input: "Tags: red,green,blue" → Tags = ["red", "green", "blue"]
SubstringBefore
C#
var template = "Email: {User:SubstringBefore('@')}";
// Input: "Email: alice@example.com" → User = "alice"
SubstringAfter
C#
var template = "Path: {Rest:SubstringAfter('/')}";
// Input: "Path: /home/alice/docs" → Rest = "home/alice/docs"
SubstringBeforeLast
C#
var template = "Path: {Dir:SubstringBeforeLast('/')}";
// Input: "Path: /home/alice/docs" → Dir = "/home/alice"
SubstringAfterLast
C#
var template = "Email: {Domain:SubstringAfterLast('@')}";
// Input: "Email: alice@example.com" → Domain = "example.com"

Type Conversion

TransformerArgumentsDescription
ToInt()Converts to int
ToDecimal()Converts to decimal
ToBoolean()Converts to bool (true/false, yes/no, on/off, 1/0)
ToGuid()Converts to Guid
ToDateTime('format',...)format stringsConverts to DateTime using specified formats
ToDateTimeUtc('format',...)format stringsConverts to UTC DateTime
ToInt
C#
var template = "Count: {Count:ToInt()}";
// Input: "Count: 42" → Count = 42 (int, not string)
ToDecimal
C#
var template = "Price: {Price:ToDecimal()}";
// Input: "Price: 9.99" → Price = 9.99 (decimal, not string)
ToBoolean
C#
var template = "Active: {IsActive:ToBoolean()}";
// Accepts: true/false, yes/no, on/off, 1/0
ToGuid
C#
var template = "Id: {Id:ToGuid()}";
// Input: "Id: 550e8400-e29b-41d4-a716-446655440000" → Id = Guid
ToDateTime
C#
var template = "Date: {Created:ToDateTime('dd/MM/yyyy','yyyy-MM-dd')}";
// Tries each format in order until one works
ToDateTimeUtc
C#
var template = "Timestamp: {Ts:ToDateTimeUtc('yyyy-MM-ddTHH:mm:ss')}";
// Input: "Timestamp: 2025-12-25T09:00:00" → Ts = DateTime (UTC kind)

Value Modification

TransformerArgumentsDescription
Set('value')fixed valueOverrides extracted value with a fixed string
DefaultValue('fallback')fallback valueReturns fallback when extracted value is null or empty
Set
C#
var template = "Role: {Role:Set('admin')}";
// Regardless of what Role matches, it is overridden to "admin"
DefaultValue
C#
var template = "Status: {Status:DefaultValue('Unknown')}";
// If Status is empty or missing, defaults to "Unknown"

Chaining Transformers

Chain multiple transformers with commas. They execute left-to-right:

C#
var template = "Email: {Email:Trim(),ToLower(),Truncate(50)}";
// 1. Trim whitespace → 2. Convert to lowercase → 3. Truncate to 50 chars

Transformers and validators can be mixed in the same chain. Validators run after transformers have modified the value.