Sha256: 62d808b674b15144a5b423b667c2051f1d8d11930f1d3ffbf9538db0f6190acf

Contents?: true

Size: 542 Bytes

Versions: 1

Compression:

Stored size: 542 Bytes

Contents

module ValidateZipcode
  class Validator
    def initialize(zipcode, locale)
      variables(zipcode, locale) unless zipcode.blank?
    end

    def valid?
      return true if @zipcode.blank?
      @match
    end

    private
      def variables(zipcode, locale)
        @zipcode = zipcode
        @match = regex_zipcode(locale.upcase)
      end

      def regex_zipcode(locale)
        if ValidateZipcode::Regex.respond_to?(locale)
          return ValidateZipcode::Regex.send(locale, @zipcode)
        end
        true
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validate_zipcode-1.0.0 lib/validate_zipcode/validator.rb