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": 7.1683,
"b": 9.2079,
"c": 10.2758
},
{
"a": 7.1683,
"b": 8.8011,
"c": 9.0578
},
{
"a": 7.1683,
"b": 12.2444,
"c": 8.6598
},
{
"a": 7.1683,
"b": 9.2079,
"c": 8.187
},
{
"a": 7.1683,
"b": 8.8011,
"c": 8.5543
},
{
"a": 7.1683,
"b": 9.2079,
"c": 9.5066
},
{
"a": 7.1683,
"b": 9.2079,
"c": 6.8894
},
{
"a": 7.1683,
"b": 12.2444,
"c": 9.8361
},
{
"a": 7.1683,
"b": 9.2079,
"c": 10.8686
},
{
"a": 7.1683,
"b": 8.8011,
"c": 12.2285
}
]

Specification

JSON schema

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