Skip to main content

Function modifiers

cardinality

Commentary

added in 0.8.3

Restricts the maximum number of unique values that a function can generate. When the limit is exceeded, previously generated values will be chosen at random.

Note that this modifier is a ceiling: if a function can't generate more unique values than the specified cardinality, it won't reach the cardinality limit.


Examples

Setting cardinality

Set cardinality to a positive integer. In this example:

  • a is only ever assigned one unique value
  • b is assigned 3 unique values, after which older values are reused
  • c always contains newly generated values
{
"a": {
"_gen": "normalDistribution",
"mean": 10,
"sd": 2,
"decimals": 4,
"cardinality": 1
},
"b": {
"_gen": "normalDistribution",
"mean": 10,
"sd": 2,
"decimals": 4,
"cardinality": 3
},
"c": {
"_gen": "normalDistribution",
"mean": 10,
"sd": 2,
"decimals": 4
}
}
[
{
"a": 8.1256,
"b": 8.8736,
"c": 12.3004
},
{
"a": 8.1256,
"b": 10.842,
"c": 8.017
},
{
"a": 8.1256,
"b": 9.4659,
"c": 11.3716
},
{
"a": 8.1256,
"b": 8.8736,
"c": 10.9777
},
{
"a": 8.1256,
"b": 9.4659,
"c": 10.8094
},
{
"a": 8.1256,
"b": 9.4659,
"c": 8.2973
},
{
"a": 8.1256,
"b": 8.8736,
"c": 10.9685
},
{
"a": 8.1256,
"b": 8.8736,
"c": 11.9964
},
{
"a": 8.1256,
"b": 8.8736,
"c": 9.212
},
{
"a": 8.1256,
"b": 8.8736,
"c": 8.3692
}
]

Specification

JSON schema

{
"type": "integer",
"minimum": 1
}