Value Types
Value Types
Section titled “Value Types”scaf supports several value types for inputs, expected outputs, and assertions.
Strings
Section titled “Strings”Quoted Strings
Section titled “Quoted Strings”Double or single quotes:
name: "Alice"status: 'active'message: "Hello, World!"path: '/usr/local/bin'Escape Sequences
Section titled “Escape Sequences”// In quoted stringsescaped: "Line 1\nLine 2"tab: "Column1\tColumn2"quote: "She said \"Hello\""backslash: "C:\\path\\to\\file"| Escape | Character |
|---|---|
\" | Double quote |
\' | Single quote |
\\ | Backslash |
\n | Newline |
\t | Tab |
\r | Carriage return |
Raw Strings
Section titled “Raw Strings”Backtick-delimited, no escape processing:
fn Example ` SELECT * FROM users WHERE name = 'Alice'`Raw strings preserve all content literally, including newlines and special characters.
Numbers
Section titled “Numbers”Integers
Section titled “Integers”count: 42negative: -17zero: 0Floats
Section titled “Floats”price: 19.99rate: 0.05negative: -3.14Alternate Bases
Section titled “Alternate Bases”// Hexadecimalhex: 0xFFhex2: 0x1a2b3c
// Binarybinary: 0b1010bits: 0b11110000
// Octaloctal: 0o755permissions: 0o644Scientific Notation
Section titled “Scientific Notation”large: 1e10small: 1.5e-5precise: 6.022e23Underscores
Section titled “Underscores”Underscores improve readability:
million: 1_000_000binary: 0b1111_0000_1111_0000hex: 0xFF_FF_FFBooleans
Section titled “Booleans”verified: truedeleted: falseCase-sensitive — True, TRUE, FALSE are invalid.
deletedAt: nulloptionalField: nullUse null to assert that a field is null/missing.
Ordered collections:
// Empty listempty: []
// Simple valuesnumbers: [1, 2, 3, 4, 5]strings: ["a", "b", "c"]mixed: [1, "two", true, null]
// Nested listsmatrix: [[1, 2], [3, 4], [5, 6]]
// Trailing comma alloweditems: [ "first", "second", "third",]List in Assertions
Section titled “List in Assertions”assert { (len(items) > 0) (items[0] == "first") ("admin" in roles)}Key-value objects:
// Empty mapempty: {}
// Simple mapuser: {name: "Alice", age: 30}
// Nested mapsconfig: { database: { host: "localhost", port: 5432 }, cache: { enabled: true, ttl: 3600 }}
// Trailing comma allowedoptions: { key1: "value1", key2: "value2",}Map Keys
Section titled “Map Keys”Keys must be valid identifiers (no quotes):
// Validdata: {name: "Alice", userId: 1}
// Invalid - no quoted keysdata: {"user-name": "Alice"} // Error!Map in Assertions
Section titled “Map in Assertions”assert { (user.name == "Alice") (user.profile.theme == "dark") (config["timeout"] > 0)}Type Coercion
Section titled “Type Coercion”scaf compares values with type awareness:
| Expected | Actual | Result |
|---|---|---|
1 (int) | 1.0 (float) | Match ✓ |
"1" (string) | 1 (number) | No match ✗ |
true | 1 | No match ✗ |
null | missing field | Match ✓ |
[] | [] | Match ✓ |
[1, 2] | [2, 1] | No match ✗ (order matters) |
Nested Structures
Section titled “Nested Structures”Complex nested data:
test "complex data" { $input: { users: [ {id: 1, name: "Alice", roles: ["admin", "user"]}, {id: 2, name: "Bob", roles: ["user"]} ], config: { features: { beta: true, legacy: false } } }
result.users[0].name: "Alice" result.users[0].roles: ["admin", "user"] result.config.features.beta: true}Database Type Mapping
Section titled “Database Type Mapping”How database types map to scaf types:
Neo4j/Cypher
Section titled “Neo4j/Cypher”| Neo4j Type | scaf Type |
|---|---|
| String | string |
| Integer | number |
| Float | number |
| Boolean | boolean |
| Null | null |
| List | list |
| Map | map |
| Node | map (properties) |
| Relationship | map (properties) |
| Date | string (ISO format) |
| DateTime | string (ISO format) |
| Duration | string |
SQL (Coming)
Section titled “SQL (Coming)”| SQL Type | scaf Type |
|---|---|
| VARCHAR, TEXT | string |
| INT, BIGINT | number |
| FLOAT, DECIMAL | number |
| BOOLEAN | boolean |
| NULL | null |
| ARRAY | list |
| JSON, JSONB | map |
| DATE | string (ISO format) |
| TIMESTAMP | string (ISO format) |