module Validatable
  extend ActiveSupport::Concern

  included do
    after_initialize do
      @custom_errors = []
    end

    validate :no_custom_errors
  end

  def add_custom_error(attribute, msg)
    @custom_errors << [attribute, msg]
  end

  def no_custom_errors
    @custom_errors.each do |error|
      errors.add(error.first, error.second)
    end
  end
end
