Sha256: 54e09fa435c4900ef247bf0ab8bf4dbabd67c1b90667a55ec2dbd7a70545379f

Contents?: true

Size: 523 Bytes

Versions: 5

Compression:

Stored size: 523 Bytes

Contents

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

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

    private
      def variables(locale)
        @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

5 entries across 5 versions & 1 rubygems

Version Path
validate_zipcode-1.3.0 lib/validate_zipcode/validator.rb
validate_zipcode-1.2.1 lib/validate_zipcode/validator.rb
validate_zipcode-1.2.0 lib/validate_zipcode/validator.rb
validate_zipcode-1.1.1 lib/validate_zipcode/validator.rb
validate_zipcode-1.1.0 lib/validate_zipcode/validator.rb