# Help, do i need to validates\_length\_of these?

**URL:** <https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131>\
**Category:** Rails\
**Created:** [April 28, 2007, 12:10am UTC](https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131 "2007-04-28T00:10:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [April 28, 2007, 12:10am UTC](https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131/1 "2007-04-28T00:10:49Z")

</div>

Hi, i’m using postgres and rails, and i’ve some fields, like first name,  
last name, etc, i’ve set it with the migration to a maximum of 50 chars,  
and i’ve limited in the view the possibility to insert more than 50  
chars… have i also to add a validates\_length\_of in the model for all  
of these fields? Which problems may i have to don’t put it?

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [April 28, 2007, 12:19am UTC](https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131/2 "2007-04-28T00:19:29Z")

</div>

> Hi, i’m using postgres and rails, and i’ve some fields, like first name,  
> last name, etc, i’ve set it with the migration to a maximum of 50 chars,  
> and i’ve limited in the view the possibility to insert more than 50  
> chars… have i also to add a validates\_length\_of in the model for all  
> of these fields? Which problems may i have to don’t put it?

Any chance you’ll ever manage that data outside of your views? Perhaps  
in  
a custom script, or via ./script/console? It certainly doesn’t hurt to  
do  
it there as well…

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [April 28, 2007, 12:55am UTC](https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131/3 "2007-04-28T00:55:32Z")

</div>

Hi Mike,

mike wrote:

> Hi, i’m using postgres and rails, and i’ve some fields, like first name,  
> last name, etc, i’ve set it with the migration to a maximum of 50 chars,  
> and i’ve limited in the view the possibility to insert more than 50  
> chars… have i also to add a validates\_length\_of in the model for all  
> of these fields? Which problems may i have to don’t put it?

I’ve been told that if I don’t validate in my model, my application is  
potentially open to non-browser based attacks, both on the app and on  
the  
database.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [April 28, 2007, 1:30pm UTC](https://www.ruby-forum.com/t/help-do-i-need-to-validates-length-of-these/93131/4 "2007-04-28T13:30:49Z")

</div>

Bill W. wrote:

> I’ve been told that if I don’t validate in my model, my application is  
> potentially open to non-browser based attacks, both on the app and on  
> the  
> database.
> 
> hth,  
> Bill

ok, i think i’ll put it on all of them 🙂
