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,
15,
5.5592880365292405,
13.650239440576705,
14.93798967186909,
7.30104878878654,
5.876774078835003,
6.521491363725756,
7.565249240391748,
3.22194071566625
]
Specification
JSON schema
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"oneOf": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}
}