Dry way to validate custom form fields


#1

Hello
I have a controller where I`m implementing a batch/bulk create action
so I can create bulks of items to a model.
The controller have a create_range function where the form sends params
like this:

params[:range_count_from]
params[:range_count_to]
params[:range_pre_text]
params[:range_post_text]

Is there a simple way to add ActiveRecord kind of validation on them?
For instance the text_field for range_count_from, would like to
validate as a positive Integer.

what is the DRY`est way of doing this… I would like to have as few If
as possible…
What is the Rails way of doing this? Should it be handled in controller
or model?

/MartOn


#2

Nobody with a good example for me?