Variable validation for user input

Is there an easy way to validate user imputed variables in a playbook? I am taking in an IP address from a vars_prompt and I just want to validate the variable to make sure the IP does not have any typos before using it in a lineinfile task. Do I need to make a module for this or am I just missing an easier way?

Example: I input 123,53,56,2 it should fail (or auto correct) because it has commas instead of periods. Or 1111.23.3.4 should fails since 1111 is not a valid octet. I just want to protect against a typo before it writes to the file.