Skip to main content

Value DSL

The Value DSL is Fascia's restricted expression language for defining computed values, transition guards, invariants, and data transformations. It is intentionally limited -- no function definitions, no loops, no side effects. Every expression is a pure computation that produces a result from existing data.

Value DSL expressions appear throughout Fascia specs:

  • Entity invariants -- Business rules that must always hold true
  • Status machine guards -- Conditions that must be met for a transition to occur
  • Flow Transform nodes -- Data transformations between flow steps
  • If/Switch conditions -- Branching logic in flow graphs
  • Policy conditions -- Rules evaluated by the Risk Engine

Operators

Arithmetic

OperatorDescriptionExample
+Additionorder.subtotal + order.tax
-Subtractionorder.total - order.discount
*Multiplicationitem.price * item.quantity
/Divisiontotal / count
%Moduloindex % 2

Comparison

OperatorDescriptionExample
==Equalorder.status == "confirmed"
!=Not equaluser.role != "guest"
>Greater thanreservation.totalPrice > 0
<Less thannow() < reservation.startDate
>=Greater than or equalaccount.balance >= withdrawal.amount
<=Less than or equaldeposit <= totalPrice

Logical

OperatorDescriptionExample
&&Logical ANDisActive && isVerified
||Logical ORisAdmin || isStaff
!Logical NOT!isDeleted

Member Access

Use dot notation to access fields on entities and nested objects:

reservation.totalPrice
reservation.customer.name
input.paymentMethod

Built-in Functions

String

FunctionSignatureDescription
concatconcat(a, b, ...)Concatenate strings
lengthlength(str)String length
substringsubstring(str, start, end)Extract substring
toLowerCasetoLowerCase(str)Convert to lowercase
toUpperCasetoUpperCase(str)Convert to uppercase
trimtrim(str)Remove leading/trailing whitespace
startsWithstartsWith(str, prefix)Check if string starts with prefix
endsWithendsWith(str, suffix)Check if string ends with suffix
containscontains(str, search)Check if string contains substring
replacereplace(str, search, replacement)Replace first occurrence
splitsplit(str, delimiter)Split string into list

Date

FunctionSignatureDescription
nownow()Current date and time
addDaysaddDays(date, days)Add days to a date
addHoursaddHours(date, hours)Add hours to a date
diffDaysdiffDays(date1, date2)Difference in days between two dates
formatformat(date, pattern)Format date as string

Math

FunctionSignatureDescription
absabs(n)Absolute value
ceilceil(n)Round up
floorfloor(n)Round down
roundround(n)Round to nearest integer
minmin(a, b)Smaller of two values
maxmax(a, b)Larger of two values

Aggregation

FunctionSignatureDescription
sumsum(list, field)Sum a field across a list
countcount(list)Count items in a list
avgavg(list, field)Average a field across a list

Type

FunctionSignatureDescription
toStringtoString(value)Convert to string
toNumbertoNumber(value)Convert to number
isNullisNull(value)Check if value is null
coalescecoalesce(a, b)Return first non-null value

Conditional

FunctionSignatureDescription
ifif(condition, thenValue, elseValue)Conditional expression

Example Expressions

Calculate 10% of a total:

reservation.totalPrice * 0.1

Conditional display text:

if(order.status == "pending", "Waiting for confirmation", "Processed")

Duration in days:

diffDays(reservation.endDate, reservation.startDate)

Check a business rule:

reservation.depositAmount <= reservation.totalPrice && reservation.totalPrice > 0

Format a summary string:

concat("Order #", toString(order.id), " - ", toUpperCase(order.status))

Constraints

The Value DSL is deliberately restricted for safety and predictability:

ConstraintLimit
No function definitionsYou cannot define custom functions
No loops or recursionIteration is not supported
No variable mutationAll expressions are pure; no assignment
No external callsCannot call APIs or services
No system callsCannot access the filesystem, network, or OS
Maximum expression depth256 levels of nesting
Maximum AST nodes1000 nodes per expression

These constraints ensure that every Value DSL expression terminates in bounded time with no side effects, making the runtime fully deterministic.