openaustralia/atdis

View on GitHub
lib/atdis/models/address.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module ATDIS
  module Models
    class Address < Model
      field_mappings(
        street: String,
        suburb: String,
        postcode: String,
        state: String
      )

      # Mandatory parameters
      validates :street, :suburb, :postcode, :state,
                presence_before_type_cast: { spec_section: "4.3.3" }

      validates :postcode, format: {
        with: /\A[0-9]{4}\z/,
        message: ATDIS::ErrorMessage.new("is not a valid postcode", "4.3.3")
      }
    end
  end
end