# How to validate presence of phone number or mobile phone

**URL:** <https://www.ruby-forum.com/t/how-to-validate-presence-of-phone-number-or-mobile-phone/176277>\
**Category:** Deployment\
**Created:** [September 28, 2009, 1:49pm UTC](https://www.ruby-forum.com/t/how-to-validate-presence-of-phone-number-or-mobile-phone/176277 "2009-09-28T13:49:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thriving](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@thriving](https://www.ruby-forum.com/u/thriving)\
**Post date:** [September 28, 2009, 1:49pm UTC](https://www.ruby-forum.com/t/how-to-validate-presence-of-phone-number-or-mobile-phone/176277/1 "2009-09-28T13:49:33Z")

</div>

In my model of user.rb

there are phone number and mobile number.

i want to validate if phone number and mobile number are exist or  
not(not neccessary to do both).

how to do that

---

<div class="post-metadata">

**Author:** ![thriving](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecae2f/32.png) [@thriving](https://www.ruby-forum.com/u/thriving)\
**Post date:** [September 29, 2009, 1:03pm UTC](https://www.ruby-forum.com/t/how-to-validate-presence-of-phone-number-or-mobile-phone/176277/2 "2009-09-29T13:03:20Z")

</div>

Thriving K. wrote:

> In my model of user.rb
> 
> there are phone number and mobile number.
> 
> i want to validate if phone number and mobile number are exist or  
> not(not neccessary to do both).
> 
> how to do that

Write following code in model.

validates\_presences\_of :field\_name
