環境
Rails 6.0.1
Ruby 2.6.3
PostgreSQL 11.16
判定方法①
phone_number = '090-1234-5678'
nil != (phone_number =~ /\A[0-9]+\z/)
# => false
phone_number = '09012345678'
nil != (phone_number =~ /\A[0-9]+\z/)
# => true
判定方法②
①よりコードをみたとき直感で分かる
phone_number = '090-1234-5678'
phone_number.match?(/\A[0-9]+\z/)
# => false
phone_number = '09012345678'
phone_number.match?(/\A[0-9]+\z/)
# => true
参考