# Different messages for different conditions in one assert

**URL:** <https://forum.ansible.com/t/different-messages-for-different-conditions-in-one-assert/45266>\
**Category:** Guides, FAQs & Howtos\
**Tags:** cfgmgmgtcamp, howto, ansible-core\
**Created:** [February 5, 2026, 8:06am UTC](https://forum.ansible.com/t/different-messages-for-different-conditions-in-one-assert/45266 "2026-02-05T08:06:04Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![kks](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kks/32/10352_2.png) [@kks](https://forum.ansible.com/u/kks)\
**Post date:** [July 26, 2026, 7:31am UTC](https://forum.ansible.com/t/different-messages-for-different-conditions-in-one-assert/45266/12 "2026-07-26T07:31:19Z")

</div>

> [@felixfontein](#):
>
> Regarding the assertions: how about making an action plugin that is similar to `ansible.builtin.assert`, but more flexible?

After quite some time, I am ready to share this plugin -

[https://galaxy.ansible.com/ui/repo/published/capable/core212/content/action/validate\_vars/](https://galaxy.ansible.com/ui/repo/published/capable/core212/content/action/validate_vars/)

There is an issue with galaxy - so documentation is not properly rendered for plugins. I am sorry for that.

Main use case for this plugin is to validate variables, but there is a nice bonus - you can have asserts with it like so:

```yaml
- capable.core212.validate_vars:
    any:
      type: any
      custom_validation:
        - condition: variable1 | int > 100
          error_message: "variable1 must be greater than 100."
        - condition: variable2 | int < 0
          error_message: "variable2 must be less than 0."

```

And even more, plugin supports `mutually_exclusive`, `required_together`, `required_one_of`, `required_if`, `required_by` but for ansible variables (not module arguments)

See [Ansible is capable of many things - #19 by kks](https://forum.ansible.com/t/ansible-is-capable-of-many-things/45931/19)

---

_[View the full topic](https://forum.ansible.com/t/different-messages-for-different-conditions-in-one-assert/45266)._
