Module: Validations::LocalAuthorityValidations

Defined in:
local_authority_validations.rb

Instance Method Summary collapse

Instance Method Details

#validate_previous_accommodation_postcode(record) ⇒ Object



2
3
4
5
6
7
8
# File 'local_authority_validations.rb', line 2

def validate_previous_accommodation_postcode(record)
  postcode = record.ppostcode_full
  if record.previous_postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
    error_message = I18n.t("validations.postcode")
    record.errors.add :ppostcode_full, :wrong_format, message: error_message
  end
end