rails serialized array validation

activemodel, activerecord, ruby-on-rails, serialization, validation

Solution

I ended up with this: https://gist.github.com/amenzhinsky/c961f889a78f4557ae0b

You can write your own `EmailValidator` according to rails guide and use the `ArrayValidator` like:

validates :emails, array: { email: true }

Problem

I need to validate email saving in email_list. For validation I have EmailValidator. But I cannot figure out how to use it in pair of validates_each. Are there any other ways to make validations? ``` class A < ActiveRecord::Base serialize :email_list validates_each :email_list do |r, a, v| # what should it be here? # EmailValidator.new(options).validate_each r, a, v end end ```

Original source