# Question about required\_if documentation

**URL:** <https://forum.ansible.com/t/question-about-required-if-documentation/44599>\
**Category:** Get Help\
**Created:** [October 2, 2025, 7:57am UTC](https://forum.ansible.com/t/question-about-required-if-documentation/44599 "2025-10-02T07:57:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ildjarn](https://avatars.discourse-cdn.com/v4/letter/i/8491ac/32.png) [@ildjarn](https://forum.ansible.com/u/ildjarn)\
**Post date:** [October 2, 2025, 7:57am UTC](https://forum.ansible.com/t/question-about-required-if-documentation/44599/1 "2025-10-02T07:57:42Z")

</div>

Hello,

I have a question about required\_if:  
From the documentation ([Ansible module architecture — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#ansiblemodule)):

* * *

required\_if:

Must be a sequence of sequences. Every inner sequence describes one conditional dependency. Every sequence must have three or four values. The first two values are the option’s name and the option’s value which describes the condition. The further elements of the sequence are only needed if the option of that name has precisely this value.

If you want that all options in a list of option names are specified if the condition is met, use one of the following forms:

```auto
('option_name', option_value, ('option_a', 'option_b', ...)),
('option_name', option_value, ('option_a', 'option_b', ...), False),

```

* * *

So I made a spec with the following (partial) content:

```auto
        update=dict(
            type="dict",
            required=True,
            options=dict(
                accountname=dict(type="str", required=False),
                passwordpolicy=dict(type="str", required=False),
                reset_passwordpolicy=dict(type="bool", required=False),
                totp_secret=dict(type="str", required=False, no_log=True),
                reset_totp=dict(type="bool", required=False),
                disable_passwordreset=dict(type="bool", required=False),
                notes=dict(type="list", required=False, elements="str"),
                append_notes=dict(type="bool", required=False, default=False),
            ),
            mutually_exclusive=[
                ("passwordpolicy", "resetpasswordpolicy"),
                ("totp_secret", "reset_totp"),
            ],
            required_if=[("append_notes", True, ("notes"))],
        )

```

However, this results in: `append_notes is True but all of the following are missing: n, o, t, e, s found in update`.

When I change the required\_if to `required_if=[("append_notes", True, ["notes"])]` (so with `[]` around the 3rd parameter instead of `()`) everything works.

Is this a documentation error? An error on my side?

Python version used: 3.12.11  
Ansible version used: 2.18.9

---

<div class="post-metadata">

**Author:** ![mkrizek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mkrizek/32/2055_2.png) [@mkrizek](https://forum.ansible.com/u/mkrizek)\
**Post date:** [October 2, 2025, 8:19am UTC](https://forum.ansible.com/t/question-about-required-if-documentation/44599/2 "2025-10-02T08:19:23Z")

</div>

`("notes")` is a string, only wrapped in parentheses; so it is a sequence of individual characters in the string which is what the error message says: `n, o, t, e, s`.

`["notes"]` is a list of strings, just one in this example and that gives you the result you expected.

I believe your original intent was to use a `tuple`, to do that you need to differentiate between a string wrapped in parentheses and a tuple by putting a comma there: `("notes",)`.

So `required_if=[("append_notes", True, ("notes",))]` should work too.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 1, 2025, 8:19am UTC](https://forum.ansible.com/t/question-about-required-if-documentation/44599/3 "2025-11-01T08:19:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
