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": 10.6654,
"b": 11.4568,
"c": 14.3868
},
{
"a": 10.6654,
"b": 12.0109,
"c": 7.8473
},
{
"a": 10.6654,
"b": 9.2891,
"c": 9.015
},
{
"a": 10.6654,
"b": 12.0109,
"c": 10.9669
},
{
"a": 10.6654,
"b": 9.2891,
"c": 11.8215
},
{
"a": 10.6654,
"b": 12.0109,
"c": 7.289
},
{
"a": 10.6654,
"b": 12.0109,
"c": 10.4089
},
{
"a": 10.6654,
"b": 9.2891,
"c": 9.4659
},
{
"a": 10.6654,
"b": 9.2891,
"c": 9.9601
},
{
"a": 10.6654,
"b": 9.2891,
"c": 10.0386
}
]

Specification

JSON schema

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