app/models/fields/custom_field_date_pair.rb
# For rendering paired values
# Handle case where both pairs are blank
#------------------------------------------------------------------------------
For rendering paired values
Handle case where both pairs are blank
For rendering paired values Handle case where both pairs are blank
def custom_validator(obj)
    super
    if pair_id.present?
      start = CustomFieldPair.find(pair_id)
      return if start.nil?
      from = obj.send(start.name)
      to = obj.send(name)
      obj.errors.add(name.to_sym, ::I18n.t('activerecord.errors.models.custom_field.endbeforestart', field: start.label)) if from.present? && to.present? && (from > to)
    end
  end
def custom_validator ( obj ) super if pair_id . present? start = CustomFieldPair . find ( pair_id ) return if start . nil? from = obj . send ( start . name ) to = obj . send ( name ) obj . errors . add ( name . to_sym , :: I18n . t ( 'activerecord.errors.models.custom_field.endbeforestart' , field : start . label ) ) if from . present? && to . present? && ( from > to ) end end
For rendering paired values
Handle case where both pairs are blank
For rendering paired values Handle case where both pairs are blank
# validate when we get to 2nd of the pair
obj