E-commerce order

Okyline · 2026-05-30 17:13
id ecommerce.order·version 1.0.0
E-commerce order - Full Okyline features showcase
Okyline symbols reference
@
Required
Field must be present
?
Nullable
Value can be null
{ , }
String Length
Min and max characters
(...)
Value Constraint
Number ranges or enums
~ ~
Format
Regex or built-in format
[ , ]
Array Size
Min and max elements
#
Key Field
Unique identifier
!
Uniqueness
No duplicate objects
Item Constraint
For array elements
1{
2 "$version": "1.0.0",
3 "$id": "ecommerce.order",
4 "$title": "E-commerce order",
5 "$description": "E-commerce order - Full Okyline features showcase",
6 "$oky": {
7 "orderId|# ~^ORD-[0-9]{8}$~|Order identifier": "ORD-20250107",
8 "createdAt|@ ~$DateTime~|Creation date": "2025-01-07T14:30:00Z",
9 "//createdBy|~ ^[A-Z]{2}[0-9]{5}$~|Created By": "PF97877",
10 "customer|@|Customer info": {
11 "id|# (>0)": 42,
12 "email|@ ~$Email~": "alice@example.com",
13 "phone|? ~$Phone~|Optional phone": "+33612345678",
14 "type|@ ($CUSTOMER_TYPE)": "PREMIUM",
15 "$appliedIf type": {
16 "('PREMIUM')": {
17 "loyaltyPoints|@ (>=0)": 1500,
18 "discountRate|@ (0..30)": 15
19 },
20 "('BUSINESS')": {
21 "companyName|@ {2,100}": "Acme Corp",
22 "vatNumber|@ ~$VatNumber~": "FR12345678901"
23 }
24 }
25 },
26
27 "shipping|@ $ref|Shipping address": "&Address",
28 "billing|? $ref|Billing if different": "&Address",
29
30 "lines|@ [1,50] -> !|Order lines": [
31 {
32 "sku|# ~$Sku~": "PRD-00123",
33 "name|@ {2,200}": "Wireless Headphones",
34 "quantity|@ (1..999)": 2,
35 "unitPrice|@ (>0)": 79.99,
36 "lineTotal|(%LineTotal)": 159.98,
37 "category|($CATEGORY)": "ELECTRONICS"
38 }
39 ],
40
41 "payment|@": {
42 "method|@ ($PAYMENT_METHOD)": "CARD",
43 "status|@ ($PAYMENT_STATUS)": "PAID",
44 "$requiredIf status('PAID')": ["paidAt", "transactionId"],
45 "$forbiddenIf status('PENDING')": ["paidAt", "transactionId"],
46 "paidAt|~$DateTime~": "2025-01-07T14:32:00Z",
47 "transactionId|~$TransactionId~": "TXN-A1B2C3D4E5F6"
48 },
49
50 "amounts|@|Amounts": {
51 "subtotal|@ (%ValidSubtotal)": 159.98,
52 "shippingCost|@ (>=0)": 5.99,
53 "discount|@ (>=0)": 24.0,
54 "tax|@ (>=0)": 28.39,
55 "total|@ (%ValidTotal)": 170.36
56 },
57
58 "status|@ ($ORDER_STATUS)": "CONFIRMED",
59 "tags|? [0,10] -> {1,30}!|Optional tags": ["gift", "express"],
60 "notes|? {0,500}|Internal notes": "Handle with care"
61
62 },
63
64 "$defs": {
65 "Address": {
66 "street|@ {5,200}": "123 Main Street",
67 "city|@ {2,100}": "Paris",
68 "postalCode|@ ~^[0-9]{5}$~": "75001",
69 "country|@ ~^[A-Z]{2}$~": "FR"
70 }
71 },
72
73 "$format":{
74 "Phone":"^\\+[0-9]{11,14}$",
75 "VatNumber":"^[A-Z]{2}[0-9]{9,12}$",
76 "TransactionId":"^TXN-[A-Z0-9]{12}$",
77 "Sku":"^[A-Z]{3}-[0-9]{5}$"
78 },
79
80 "$nomenclature": {
81 "CUSTOMER_TYPE": "STANDARD, PREMIUM, BUSINESS",
82 "CATEGORY": "ELECTRONICS, CLOTHING, HOME, FOOD, OTHER",
83 "PAYMENT_METHOD": "CARD, PAYPAL, TRANSFER, CRYPTO",
84 "PAYMENT_STATUS": "PENDING, PAID, FAILED, REFUNDED",
85 "ORDER_STATUS": "DRAFT, CONFIRMED, SHIPPED, DELIVERED, CANCELLED"
86 },
87
88 "$compute": {
89 "LineTotal": "lineTotal == quantity * unitPrice",
90 "ValidSubtotal": "subtotal > 0 && subtotal == sum(parent.lines, lineTotal)",
91 "ValidTotal": "total > 0 && total == subtotal + shippingCost + tax - discount"
92 }
93}
94