Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created December 15, 2010 14:41
Show Gist options
  • Save rubiii/742010 to your computer and use it in GitHub Desktop.
Save rubiii/742010 to your computer and use it in GitHub Desktop.
class EsimValidator < ActiveModel::Validator
include ActiveModel::Validations
validates_presence_of :name, :voucher_type, :delivery_date, :expiration_date
validates_numericality_of :sales_partner_id, :greater_than => 1, :only_integer => true
attr_accessor :record
def errors
record.errors
end
def validate(record)
self.record = record
valid?
end
def method_missing(method, *args, &block)
super unless record && record.respond_to?(method)
record.send method, *args, &block
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment