# Validating hard-coded vs user data

**URL:** <https://www.ruby-forum.com/t/validating-hard-coded-vs-user-data/127847>\
**Category:** Rails\
**Created:** [February 1, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/validating-hard-coded-vs-user-data/127847 "2008-02-01T20:37:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eclubb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@eclubb](https://www.ruby-forum.com/u/eclubb)\
**Post date:** [February 1, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/validating-hard-coded-vs-user-data/127847/1 "2008-02-01T20:37:14Z")

</div>

I’m building validations in a model which contains user input as well as  
hard-coded and program-generated values. Is the purpose of validation  
to protect the db from bad user data, or possible programmer errors  
(typos, etc) as well? How paranoid should I be in my validations?

Earle

---

<div class="post-metadata">

**Author:** ![eclubb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@eclubb](https://www.ruby-forum.com/u/eclubb)\
**Post date:** [February 1, 2008, 10:03pm UTC](https://www.ruby-forum.com/t/validating-hard-coded-vs-user-data/127847/2 "2008-02-01T22:03:34Z")

</div>

Validate things that your application is going to rely on, regardless  
if the values are from user input or set programatically. That  
usually includes the validating presence\_of key data fields and  
associations. Stick to the important stuff and don’t waste your time  
crafting complicated validations that are just going to frustrate you  
and your users.

It’s easy to blow half a day creating a phone number regex validation  
that’s a work of art. But that falls apart when a user wants to enter  
“123-456-7890 (don’t call after 5 pm)”.

Aaron

On Feb 1, 12:37 pm, Earle C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
