Seven complete documents, each one running here in the browser, in the playground, and in the
conformance suite. Filter the list, or jump straight to one.
form portfolio version = "1.0" {
text {
"p.ticker": "Ticker""p.quantity": "Quantity""p.price": "Price""p.value": "Value""p.total": "Total value""p.largest": "Largest single holding""p.howmany": "How many holdings""p.overweight": "Any holding worth more than 10000""p.positive": "All quantities positive""p.tickers": "Tickers"
}
repeat holdings {
max = 20field ticker { type = string, label = t("p.ticker") }
field quantity { type = integer, label = t("p.quantity") }
field price { type = number, label = t("p.price") }
field value { type = number, label = t("p.value"), value = quantity * price }
}
field total {
type = number
label = t("p.total")
value = sum(item in holdings, item.value)
}
field largest {
type = number
label = t("p.largest")
value = maxOf(holdings)
}
field holding_count {
type = integer
label = t("p.howmany")
value = count(holdings)
}
field any_overweight {
type = boolean
label = t("p.overweight")
value = any(item in holdings, item.value > 10000)
}
field all_positive {
type = boolean
label = t("p.positive")
value = all(item in holdings, item.quantity > 0)
}
field tickers {
type = array of string
label = t("p.tickers")
value = map(item in holdings, item.ticker)
}
output {
total: number
largest: number
holding_count: integer
any_overweight: boolean
all_positive: boolean
tickers: array of string
}
}
form loan_application version = "1.0" {
text {
"applicant.first": "First name""applicant.last": "Last name""applicant.income": "Annual income""applicant.amount": "Loan amount""applicant.term": "Term in months""applicant.monthly": "Monthly payment""applicant.guarantor": "Guarantor name""applicant.consent": "The applicant agrees to a credit check"
}
group applicant {
field first_name {
type = string
label = t("applicant.first")
required = true
}
field last_name {
type = string
label = t("applicant.last")
required = true
}
field annual_income {
type = number
label = t("applicant.income")
validate { min = 0 }
}
field loan_amount {
type = number
label = t("applicant.amount")
validate { min = 0 }
}
field term {
type = integer
label = t("applicant.term")
default = 60
}
field monthly {
type = number
label = t("applicant.monthly")
value = pmt(0.05 / 12, term, loan_amount)
}
}
group guarantor {
field guarantor_name {
type = string
label = t("applicant.guarantor")
when = applicant.annual_income > 10000
}
field guarantor_consent {
type = boolean
label = t("applicant.consent")
when = applicant.annual_income > 10000validate { accepted }
}
}
output {
applicant.first_name: string
applicant.last_name: string
applicant.annual_income: number
applicant.loan_amount: number
applicant.term: integer
applicant.monthly: number
guarantor.guarantor_name: string
guarantor.guarantor_consent: boolean
}
}
form invoice version = "1.0" {
text {
"i.unit": "Unit price""i.quantity": "Quantity""i.subtotal": "Subtotal""i.rate": "Discount""i.discount": "Discount amount""i.total": "Total""i.vat": "VAT at 20%""i.grand": "Grand total""i.monthly": "Monthly instalment over 12 months"
}
field unit_price {
type = number
label = t("i.unit")
default = 19.99
}
field quantity {
type = integer
label = t("i.quantity")
default = 3
}
field subtotal {
type = number
label = t("i.subtotal")
value = unit_price * quantity
}
field discount_rate {
type = number
label = t("i.rate")
default = 0.075
}
field discount {
type = number
label = t("i.discount")
value = round(subtotal * discount_rate, 2)
}
field total {
type = number
label = t("i.total")
value = subtotal - discount
}
field vat {
type = number
label = t("i.vat")
value = round(total * 0.2, 2)
}
field grand_total {
type = number
label = t("i.grand")
value = total + vat
}
field monthly {
type = number
label = t("i.monthly")
value = round(grand_total / 12, 2)
}
output {
unit_price: number
quantity: integer
subtotal: number
discount: number
total: number
vat: number
grand_total: number
monthly: number
}
}