check if the previous fields input is given by the user

Hi,
I’m writing a custom module. I wanted to set some fields to “required”: True, depending upon the previous field i.e if user specified previous field then next field should be set to required:True
please see this below example and help me!

def main():

  fields = {
        "name": {"required": True, "type": "str" },
        "description": {"required": False, "type": "str"},
        "storage": {"type": "str" },
        "capacity": { # Here it should become "required": True if and only if user specifies
 storage[in play.yml] else it should be "required":False},
    }

    module = AnsibleModule(argument_spec=fields)
    module.exit_json(changed=False, meta=module.params)


I think you’d have to make a specific check for this in your code and Fail if neither storage or capacity were supplied.

Jon