# Validations Doubt

**URL:** <https://www.ruby-forum.com/t/validations-doubt/59285>\
**Category:** Rails\
**Created:** [May 3, 2006, 12:39pm UTC](https://www.ruby-forum.com/t/validations-doubt/59285 "2006-05-03T12:39:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [May 3, 2006, 12:39pm UTC](https://www.ruby-forum.com/t/validations-doubt/59285/1 "2006-05-03T12:39:25Z")

</div>

Hi to Ruby and Rails group!

I am new to the ROR .

I ahev some doubts

1.Can we write the reguller expressions controller!

2.I have added the some controles in the rhtml file.(with out database  
fileds)

I want to wirte the validations for these text fields in the model

Is it Possible?

Give me any reference?

3.In how many ways can we write the validations?

Thanks and Regards,  
Kumar

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [May 3, 2006, 1:37pm UTC](https://www.ruby-forum.com/t/validations-doubt/59285/2 "2006-05-03T13:37:50Z")

</div>

kumar wrote:

> Hi to Ruby and Rails group!
> 
> I am new to the ROR .
> 
> I ahev some doubts
> 
> 1.Can we write the reguller expressions controller!
> 
> 2.I have added the some controles in the rhtml file.(with out database  
> fileds)
> 
> I want to wirte the validations for these text fields in the model
> 
> Is it Possible?
> 
> Give me any reference?
> 
> 3.In how many ways can we write the validations?
> 
> Thanks and Regards,  
> Kumar

Hi I have also same doubt ,can we write the validations for non  
database fileds  
in model

Please give me reference

Thnks

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [May 3, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/validations-doubt/59285/3 "2006-05-03T19:07:04Z")

</div>

There is many different validations that are available to you out of the  
box.

The one for use with regular expressions is  
validates\_format\_of  
docs at  
[http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000817](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000817)

If none of those meet your exact needs you can always write your own  
with  
the validate method

---

<div class="post-metadata">

**Author:** ![kumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kumar](https://www.ruby-forum.com/u/kumar)\
**Post date:** [May 3, 2006, 4:43pm UTC](https://www.ruby-forum.com/t/validations-doubt/59285/4 "2006-05-03T16:43:48Z")

</div>

> Hi I have also same doubt ,can we write the validations for non  
> database fileds  
> in model
> 
> Please give me reference
> 
> Thnks

Yes you can I did just that in this peice of code

[http://www.metaspot.net/gms/browser/trunk/app/models/user.rb](http://www.metaspot.net/gms/browser/trunk/app/models/user.rb)
