Sha256: 03accd0a06e97174bd2368db5e67273033d8a2c632d49ff6e997386430877df0

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module NdsApi
  module Validator
    class << self
      def validate_search_providers_params!(params)
        raise "NDS API ERROR: Invalid params: #{invalid_params(params).join(' - ')}" unless invalid_params(params).empty?
      end

      private

      def invalid_params(params)
        invalid_params = []
        if params
          params.keys.each do |param|
            invalid_params << param unless is_valid_field?(param)
          end
        end
        invalid_params
      end

      def is_valid_field?(field)
        valid_fields.include?(field.to_s)
      end

      def valid_fields
        %w[agesServiced
           ageGroups
           locationA
           locationB
           distance
           zips
           attributesLocal17
           typesOfCare
           shiftType
           acceptsChildren
           yearlySchedule
           weeklySchedule
           dailySchedule
           financialAssist
           languages
           attributesLocal3
           generalLocal1
           generalLocal2
           totalVacancies
           vacanciesByAge
           vacancyDateRange
           meals
           environment
           weeklyRate
           monthtlyRate
           beforeSchool
           afterSchool
           acceptsDropIns
           rotating
           openHolidays
           tempEmergency
           open24Hours
           providerIds]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nds_api-0.1.20 lib/nds_api/validator.rb