Module: Validations::Sales::PropertyValidations
- Defined in:
- sales/property_validations.rb
Instance Method Summary collapse
- #validate_bedsit_number_of_beds(record) ⇒ Object
- #validate_postcodes_match_if_discounted_ownership(record) ⇒ Object
- #validate_uprn(record) ⇒ Object
Instance Method Details
#validate_bedsit_number_of_beds(record) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'sales/property_validations.rb', line 14 def validate_bedsit_number_of_beds(record) return unless record.proptype.present? && record.beds.present? if record.is_bedsit? && record.beds > 1 record.errors.add :proptype, I18n.t("validations.property.proptype.bedsits_have_max_one_bedroom") record.errors.add :beds, I18n.t("validations.property.beds.bedsits_have_max_one_bedroom") end end |
#validate_postcodes_match_if_discounted_ownership(record) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'sales/property_validations.rb', line 2 def validate_postcodes_match_if_discounted_ownership(record) return unless record.saledate && !record.form.start_year_after_2024? return unless record.ppostcode_full.present? && record.postcode_full.present? if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full record.errors.add :postcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") record.errors.add :ownershipsch, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") record.errors.add :uprn, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") end end |
#validate_uprn(record) ⇒ Object
23 24 25 26 27 28 29 |
# File 'sales/property_validations.rb', line 23 def validate_uprn(record) return unless record.uprn return if record.uprn.match?(/^[0-9]{1,12}$/) record.errors.add :uprn, I18n.t("validations.property.uprn.invalid") end |