Validation without saving

One of the things that strikes me as odd about the validations as I understand them to work from AWDWR, is that the validations themselves are only triggered upon a save.

I brought this up earlier that I am accustomed to doing validations of data before updating a model with it, but Rails wants to allow the modification of the model, then only bother to validate it if it is saved -- at least that's what I'm seeing at this point.

What good does that do unsaved model data? Model data that perhaps never gets saved to a database, but nonetheless must have validated data to perform its interim purpose.

What if I bring data in from a web service or a file -- isn't it best to complain to that source (or log the problem, or whatever) at the moment the data is accepted, and not some who-knows-when point which may be tainted by some other process and therefore I lose the ability to complain to the actual source that provided the bad data?

Looking at the methods in validations.rb, I'm not seeing a method that gives me arbitrary control over when to invoke validations.

I'm probably still not seeing the whole picture, but I'm getting that "something's wrong" feeling.

-- gw (www.railsdev.ws)

my_object.valid?

if you create a validate function, which automatically gets called by rails you can do

my_object.validate

there are 2 others validate_on_create and validate_on_update

the my_object.valid? method should invoke these and any of the validates_X functions

and if you want something that is unique to this data and that doesn't get saved on create your own method and call my_object.my_method_name

White Wizzard