# Server side Validation

**URL:** <https://www.ruby-forum.com/t/server-side-validation/125621>\
**Category:** Rails\
**Created:** [January 10, 2008, 5:53pm UTC](https://www.ruby-forum.com/t/server-side-validation/125621 "2008-01-10T17:53:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![atulxxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3be4f8/32.png) [@atulxxx](https://www.ruby-forum.com/u/atulxxx)\
**Post date:** [January 10, 2008, 5:53pm UTC](https://www.ruby-forum.com/t/server-side-validation/125621/1 "2008-01-10T17:53:37Z")

</div>

Hi,

Does RoR provide logical validation on the server side ? Eg checking  
whether the amount in a particular field is the correct sum or product  
of some other fields or if the value between 2 fields have some  
relation, eg they are unequal etc. If there is an error, how is it  
displayed, is a flash[:message] the best method ?

Thanks

atul

---

<div class="post-metadata">

**Author:** ![atulxxx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3be4f8/32.png) [@atulxxx](https://www.ruby-forum.com/u/atulxxx)\
**Post date:** [January 10, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/server-side-validation/125621/2 "2008-01-10T18:53:48Z")

</div>

On 10 Jan 2008, at 16:53, Atul G. wrote:

> Hi,
> 
> Does RoR provide logical validation on the server side ? Eg checking  
> whether the amount in a particular field is the correct sum or product  
> of some other fields or if the value between 2 fields have some  
> relation, eg they are unequal etc. If there is an error, how is it  
> displayed, is a flash[:message] the best method ?

There are a bunch of validations you can use on your models  
(validates\_format\_of, validates\_inclusion\_of etc…) and it’s not hard  
to right your own/customise it.

error\_messages\_for is often a decent enough presentation of errors,  
but you could also iterate over model.errors and display them whatever  
way you want

Fred
