.. _ansible.utils.validate_filter: ********************** ansible.utils.validate ********************** **Validate data with provided criteria** Version added: 1.0.0 .. contents:: :local: :depth: 1 Synopsis -------- - Validate ``data`` with provided ``criteria`` based on the validation ``engine``. Parameters ---------- .. raw:: html
Parameter Choices/Defaults Configuration Comments
criteria
raw / required
The criteria used for validation of value that represents data options.
This option represents the first argument passed in the filter plugin For example config_data|ansible.utils.validate(config_criteria), in this case the value of config_criteria represents this option.
For the type of criteria that represents this value refer documentation of individual validator plugins.
data
raw / required
A data that will be validated against criteria.
This option represents the value that is passed to filter plugin in pipe format. For example config_data|ansible.utils.validate(), in this case config_data represents this option.
For the type of data that represents this value refer documentation of individual validator plugins.
engine
string
Default:
"ansible.utils.jsonschema"
The name of the validator plugin to use.
This option can be passed in lookup plugin as a key, value pair For example config_data|ansible.utils.validate(config_criteria, engine='ansible.utils.jsonschema'), in this case the value ansible.utils.jsonschema represents the engine to be use for data valdiation. If the value is not provided the default value that is ansible.uitls.jsonschema will be used.
The value should be in fully qualified collection name format that is <org-name>.<collection-name>.<validator-plugin-name>.

Notes ----- .. note:: - For the type of options ``data`` and ``criteria`` refer the individual ``validate`` plugin documentation that is represented in the value of ``engine`` option. - For additional plugin configuration options refer the individual ``validate`` plugin documentation that is represented by the value of ``engine`` option. - The plugin configuration option can be either passed as *key=value* pairs within filter plugin or environment variables. - The precedence of the ``validate`` plugin configurable option is the variable passed within filter plugin as *key=value* pairs followed by the environment variables. Examples -------- .. code-block:: yaml - name: set facts for data and criteria set_fact: data: "{{ lookup('file', './validate/data/show_interfaces_iosxr.json')}}" criteria: "{{ lookup('file', './validate/criteria/jsonschema/show_interfaces_iosxr.json')}}" - name: validate data in json format using jsonschema with by passing plugin configuration variable as key/value pairs ansible.builtin.set_fact: data_validilty: "{{ data|ansible.utils.validate(criteria, engine='ansible.utils.jsonschema', draft='draft7') }}" Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this filter: .. raw:: html
Key Returned Description
_raw
-
If data is valid returns empty list
If data is invalid returns list of errors in data



Status ------ Authors ~~~~~~~ - Ganesh Nalawade (@ganeshrn) .. hint:: Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.