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": 12.2444,
"b": 8.6598,
"c": 10.1922
},
{
"a": 12.2444,
"b": 9.1118,
"c": 11.6171
},
{
"a": 12.2444,
"b": 9.6913,
"c": 8.5543
},
{
"a": 12.2444,
"b": 9.1118,
"c": 10.8339
},
{
"a": 12.2444,
"b": 9.6913,
"c": 7.8091
},
{
"a": 12.2444,
"b": 9.1118,
"c": 8.8852
},
{
"a": 12.2444,
"b": 9.1118,
"c": 9.9094
},
{
"a": 12.2444,
"b": 8.6598,
"c": 10.2793
},
{
"a": 12.2444,
"b": 9.6913,
"c": 10.5155
},
{
"a": 12.2444,
"b": 8.6598,
"c": 11.1124
}
]

Specification

JSON schema

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