bmel:clamp¶
Category: Math · Returns: bmel:number
Signature
bmel:clamp(expr: bmel:number, min: bmel:number, max: bmel:number)
Description¶
Constrains a value to be within the inclusive range [min, max].
Arguments¶
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | bmel:number | The numeric value to clamp. | |
min | bmel:number | The minimum allowed value (inclusive). | |
max | bmel:number | The maximum allowed value (inclusive). |
Examples¶
Keep a score between 0 and 100
bmel:clamp({invokeAgent:Response Payload}.$.score, 0, 100)
Cap a discount at 30%
bmel:clamp({createOrder:Request Payload}.$.discount_pct, 0, 30)