Function modifiers
elide
Commentary
added in 0.1.21
How frequently this generator call should be skipped, and its position in the resulting data structure erased.
The frequency can be chosen with a rate 1, presence of a value 2, or absence of a value 3. Only one can be used, so if multiple strategies are specified, they are selected in the order written here.
Examples
Eliding with a rate
Specify rate to elide a percentage of values. In this example, 50% of the values are elided.
{
    "a": {
        "_gen": "string",
        "expr": "#{Name.fullName}",
        "elide": {
            "rate": 0.7
        }
    },
    "b": {
        "_gen": "string",
        "expr": "#{Name.fullName}"
    }
}
[
    {
        "topic": "sandbox",
        "key": null,
        "value": {
            "b": "Krystin Labadie I"
        },
        "headers": null
    },
    {
        "topic": "sandbox",
        "key": null,
        "value": {
            "a": "Cecilia Watsica DDS",
            "b": "Merideth Hintz"
        },
        "headers": null
    },
    {
        "topic": "sandbox",
        "key": null,
        "value": {
            "b": "Frederick Schoen"
        },
        "headers": null
    },
    {
        "topic": "sandbox",
        "key": null,
        "value": {
            "b": "Devora Bartell"
        },
        "headers": null
    },
    {
        "topic": "sandbox",
        "key": null,
        "value": {
            "b": "Olevia Emmerich Sr."
        },
        "headers": null
    }
]
Eliding with presence
Specify whenPresent to elide when a reference value is non-null.
{
    "topic": "sandbox",
    "vars": {
        "someMap": {
            "someKey": {
                "_gen": "oneOf",
                "choices": [
                    42,
                    null
                ]
            }
        }
    },
    "value": {
        "a": {
            "_gen": "boolean",
            "elide": {
                "whenPresent": {
                    "_gen": "var",
                    "var": "someMap",
                    "path": [
                        "someKey"
                    ]
                }
            }
        },
        "b": {
            "_gen": "boolean",
            "elide": {
                "whenPresent": {
                    "_gen": "var",
                    "var": "someMap",
                    "path": [
                        "missingKey"
                    ]
                }
            }
        }
    }
}
[
    {
        "b": true
    },
    {
        "b": false
    },
    {
        "a": false,
        "b": true
    },
    {
        "b": true
    },
    {
        "a": true,
        "b": true
    }
]
Eliding with absence
Specify whenAbsent to elide when a reference value is false or null.
{
    "topic": "sandbox",
    "vars": {
        "someMap": {
            "someKey": 42
        }
    },
    "value": {
        "a": {
            "_gen": "boolean",
            "elide": {
                "whenAbsent": {
                    "_gen": "var",
                    "var": "someMap",
                    "path": [
                        "someKey"
                    ]
                }
            }
        },
        "b": {
            "_gen": "boolean",
            "elide": {
                "whenAbsent": {
                    "_gen": "var",
                    "var": "someMap",
                    "path": [
                        "missingKey"
                    ]
                }
            }
        }
    }
}
[
    {
        "a": true
    },
    {
        "a": false
    },
    {
        "a": false
    },
    {
        "a": false
    },
    {
        "a": false
    }
]
Specification
JSON schema
{
    "type": "object",
    "properties": {
        "elide": {
            "type": "object",
            "properties": {
                "rate": {
                    "oneOf": [
                        {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                        },
                        {
                            "type": "object",
                            "properties": {
                                "_gen": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "_gen"
                            ]
                        }
                    ]
                },
                "whenPresent": {
                    "type": "object",
                    "properties": {
                        "_gen": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "_gen"
                    ]
                },
                "whenAbsent": {
                    "type": "object",
                    "properties": {
                        "_gen": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "_gen"
                    ]
                }
            },
            "oneOf": [
                {
                    "required": [
                        "rate"
                    ]
                },
                {
                    "required": [
                        "whenPresent"
                    ]
                },
                {
                    "required": [
                        "whenAbsent"
                    ]
                }
            ]
        }
    }
}