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.1287,
"b": 10.3735,
"c": 8.9359
},
{
"a": 10.1287,
"b": 10.1096,
"c": 12.9537
},
{
"a": 10.1287,
"b": 9.0854,
"c": 13.0205
},
{
"a": 10.1287,
"b": 9.0854,
"c": 8.5752
},
{
"a": 10.1287,
"b": 10.3735,
"c": 11.6376
},
{
"a": 10.1287,
"b": 9.0854,
"c": 11.4993
},
{
"a": 10.1287,
"b": 10.1096,
"c": 7.7116
},
{
"a": 10.1287,
"b": 10.3735,
"c": 8.4038
},
{
"a": 10.1287,
"b": 10.3735,
"c": 9.5012
},
{
"a": 10.1287,
"b": 10.1096,
"c": 6.816
}
]

Specification

JSON schema

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