Module: Validations::DateValidations
- Includes:
- SharedValidations
- Defined in:
- date_validations.rb
Instance Method Summary collapse
- #validate_property_major_repairs(record) ⇒ Object
- #validate_property_void_date(record) ⇒ Object
- #validate_startdate(record) ⇒ Object
Instance Method Details
#validate_property_major_repairs(record) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'date_validations.rb', line 4 def validate_property_major_repairs(record) date_valid?("mrcdate", record) if record["startdate"].present? && record["mrcdate"].present? && record["startdate"] < record["mrcdate"] record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.before_tenancy_start") end if is_rsnvac_first_let?(record) && record["mrcdate"].present? record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let") end if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start") end end |
#validate_property_void_date(record) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'date_validations.rb', line 19 def validate_property_void_date(record) if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650 record.errors.add :voiddate, I18n.t("validations.property.void_date.ten_years_before_tenancy_start") end if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date < record["voiddate"].to_date record.errors.add :voiddate, I18n.t("validations.property.void_date.before_tenancy_start") end if record["voiddate"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["voiddate"].to_date record.errors.add :voiddate, :after_mrcdate, message: I18n.t("validations.property.void_date.after_mrcdate") record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.before_void_date") end end |
#validate_startdate(record) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'date_validations.rb', line 34 def validate_startdate(record) return unless record.startdate && date_valid?("startdate", record) if record["voiddate"].present? && record.startdate < record["voiddate"] record.errors.add :startdate, I18n.t("validations.setup.startdate.after_void_date") end if record["mrcdate"].present? && record.startdate < record["mrcdate"] record.errors.add :startdate, I18n.t("validations.setup.startdate.after_major_repair_date") end if record["voiddate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650 record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_void_date") end if record["mrcdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_mrc_date") end end |