Skip to main content

Function modifiers

clamp

Commentary

added in 0.7.12

Restricts a numeric value within a given lower and upper range.


Examples

Clamping to literal values

Use clamp with a minimum and maxiumum value. In this example, the value will never be below 2 or above 15.

{
"_gen": "normalDistribution",
"mean": 10,
"sd": 7,
"clamp": [
2,
15
]
}
[
15,
2,
2,
2.6379589417661986,
15,
11.83038919130422,
15,
15,
2,
6.789863155486735
]

Specification

JSON schema

{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}
}