Module: Validations::TenancyValidations
- Includes:
- SharedValidations
- Defined in:
- tenancy_validations.rb
Instance Method Summary collapse
- #validate_general_needs_fixed_tenancy_length_affordable_social_rent(record) ⇒ Object
- #validate_general_needs_fixed_tenancy_length_intermediate_rent(record) ⇒ Object
- #validate_joint_tenancy(record) ⇒ Object
- #validate_other_tenancy_type(record) ⇒ Object
- #validate_periodic_tenancy_length(record) ⇒ Object
- #validate_supported_housing_fixed_tenancy_length(record) ⇒ Object
- #validate_tenancy_length_blank_when_not_required(record) ⇒ Object
Instance Method Details
#validate_general_needs_fixed_tenancy_length_affordable_social_rent(record) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'tenancy_validations.rb', line 19 def (record) return unless record.tenancy_type_fixed_term? && record. && record.is_general_needs? return if record.tenancylength.blank? min_tenancy_length = 2 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, record.errors.add :rent_type, record.errors.add :tenancylength, :tenancylength_invalid, message: record.errors.add :tenancy, end |
#validate_general_needs_fixed_tenancy_length_intermediate_rent(record) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'tenancy_validations.rb', line 33 def validate_general_needs_fixed_tenancy_length_intermediate_rent(record) return unless record.tenancy_type_fixed_term? && !record. && record.is_general_needs? return if record.tenancylength.blank? min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, record.errors.add :rent_type, record.errors.add :tenancylength, :tenancylength_invalid, message: record.errors.add :tenancy, end |
#validate_joint_tenancy(record) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'tenancy_validations.rb', line 71 def validate_joint_tenancy(record) return unless record.collection_start_year && record.joint if record.hhmemb == 1 && record.joint == 1 && record.collection_start_year >= 2022 record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.tenancy.not_joint") record.errors.add :hhmemb, I18n.t("validations.tenancy.joint_more_than_one_member") end end |
#validate_other_tenancy_type(record) ⇒ Object
67 68 69 |
# File 'tenancy_validations.rb', line 67 def validate_other_tenancy_type(record) validate_other_field(record, 3, :tenancy, :tenancyother, "tenancy type", "other tenancy type") end |
#validate_periodic_tenancy_length(record) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'tenancy_validations.rb', line 47 def validate_periodic_tenancy_length(record) return unless record.is_periodic_tenancy? && record.tenancylength.present? min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) = I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:) record.errors.add :tenancylength, :tenancylength_invalid, message: record.errors.add :tenancy, end |
#validate_supported_housing_fixed_tenancy_length(record) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'tenancy_validations.rb', line 6 def validate_supported_housing_fixed_tenancy_length(record) return unless record.tenancy_type_fixed_term? && record.is_supported_housing? return if record.tenancylength.blank? min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) record.errors.add :needstype, record.errors.add :tenancylength, :tenancylength_invalid, message: record.errors.add :tenancy, end |
#validate_tenancy_length_blank_when_not_required(record) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'tenancy_validations.rb', line 58 def validate_tenancy_length_blank_when_not_required(record) return if record.tenancylength.blank? return if record.tenancy_type_fixed_term? || record.is_periodic_tenancy? = I18n.t("validations.tenancy.length.fixed_term_not_required") record.errors.add :tenancylength, :tenancylength_invalid, message: record.errors.add :tenancy, end |