Selection functions
oneOf
Commentary
added in 0.0.5
Randomly selects a choice with equal probability.
Examples
Literal choices
{
"_gen": "oneOf",
"choices": [
"a",
"b",
"c"
]
}
[
"c",
"c",
"a",
"c",
"c"
]
Function choices
Each choice can be another generator.
{
"_gen": "oneOf",
"choices": [
{
"_gen": "string",
"expr": "#{Name.fullName}"
},
{
"_gen": "uniformDistribution",
"bounds": [
0,
5
]
},
{
"_gen": "boolean"
}
]
}
[
"Ezra Hansen",
true,
false,
false,
1.4544751882991673
]
Specification
JSON schema
{
"type": "object",
"properties": {
"choices": {
"oneOf": [
{
"type": "array",
"minItems": 1
},
{
"type": "object",
"properties": {
"_gen": {
"type": "string"
}
},
"required": [
"_gen"
]
}
]
}
},
"required": [
"choices"
]
}