I want to check if the variable which is basically a user input is a 10 digit phone number or not.
There are 2 sets of validations: - If num is less than 10 digit then prompt a msg - if num is a string instead rather than integer
@phone = params[:phone_num]
puts "phone_num: #{@phone}"
if @phone.is_a? Integer
puts "phone_num is int"
if @phone.to_s.length == 10
puts "10 digit"
perform(@phone)
@output = "Valid Number, will receive a call"
end
else
puts "Wont be calling"
@output = "The number is invalid"
end
The output that I get is always The number is invalid
no matter what I enter in text box. There are many stack overflow answering dealing with different questions but wondering why my code didn't work.