Hi,

I'm looking for an example as to how to use the validate_associated 
plugin.  Here's an example of what I'm trying to do.

class Address < Sequel::Model
  plugin :validation_helpers
  
  many_to_one :sales_order, key: :link_no, primary_key: :order_no

  def validate
    super
    validates_presence :name
  end
end

class SalesOrder < Sequel::Model
  plugin :validation_helpers
  plugin :validate_associated
  
  one_to_one :shipping_address, class: Address, conditions: {addr_type: 
'S'}, key: :link_no, primary_key: :order_no

  private

  def validate
    super
    validates_presence [..., ..., ...]
  end
end

so = SalesOrder[1234]
so.shipping_address.name = nil
so.valid?  #  true  (expected false because shipping_address.name is not 
present)








-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to