I am trying to check that 3 condiditons are met when asking a user for an email. The user must input something, they must include the @ symbol, and include a domain (.com, .edu, .net, etc). For the domian I am mainly checking for a period. how do i make sure the user input meets these 3 conditions?
Here is the code I use:
def email()
print "What is the students email? "
email = gets.chomp
if email.empty? && email.include?("@") && email.include?(".")
puts "working"
else
puts "Please enter a valid email. "
email()
end
end
email()
Here is an example of me running the method in terminal:
I am using Ruby and VScode.