lib/vwo/utils/validations.rb
# Validates if the value passed batch_events has correct data type and values or not.
#
# Args: batch_events [Hash]: value to be tested
#
# @return: [Boolean]: True if all conditions are passed else False
Validates if the value passed batch_events has correct data type and values or not.
Args: batch_events [Hash]: value to be tested
Validates if the value passed batch_events has correct data type and values or not . Args : batch_events [ Hash ] : value to be tested
def is_valid_batch_event_settings(batch_events)
        logger = VWO::Logger.get_instance
        events_per_request = batch_events[:events_per_request]
        request_time_interval = batch_events[:request_time_interval]
        unless events_per_request || request_time_interval
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::EVENT_BATCHING_INSUFFICIENT,
              file: VWO::FileNameEnum::ValidateUtil
            )
          )
          return false
        end
        if (request_time_interval && !valid_number?(request_time_interval))
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::REQUEST_TIME_INTERVAL_INVALID,
              file: VWO::FileNameEnum::ValidateUtil
            )
          )
          return false
        end
        if (events_per_request && !valid_number?(events_per_request))
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::EVENTS_PER_REQUEST_INVALID,
              file: VWO::FileNameEnum::ValidateUtil
            )
          )
          return false
        end
        if events_per_request && (events_per_request < VWO::MIN_EVENTS_PER_REQUEST || events_per_request > VWO::MAX_EVENTS_PER_REQUEST)
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::EVENTS_PER_REQUEST_OUT_OF_BOUNDS,
              file: VWO::FileNameEnum::ValidateUtil,
              min_value: VWO::MIN_EVENTS_PER_REQUEST,
              max_value: VWO::MAX_EVENTS_PER_REQUEST
            )
          )
          return false
        end
        if request_time_interval && request_time_interval < VWO::MIN_REQUEST_TIME_INTERVAL
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::REQUEST_TIME_INTERVAL_OUT_OF_BOUNDS,
              file: VWO::FileNameEnum::ValidateUtil,
              min_value: VWO::MIN_REQUEST_TIME_INTERVAL
            )
          )
          return false
        end
        if batch_events.key?(:flushCallback) && !batch_events[:flushCallback].is_a?(Method)
          logger.log(
            VWO::LogLevelEnum::ERROR,
            format(
              VWO::LogMessageEnum::ErrorMessages::FLUSH_CALLBACK_INVALID,
              file: VWO::FileNameEnum::ValidateUtil
            )
          )
          return false
        end
        true
      end
def is_valid_batch_event_settings ( batch_events ) logger = VWO :: Logger . get_instance events_per_request = batch_events [ :events_per_request ] request_time_interval = batch_events [ :request_time_interval ] unless events_per_request || request_time_interval logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: EVENT_BATCHING_INSUFFICIENT , file : VWO :: FileNameEnum :: ValidateUtil ) ) return false end if ( request_time_interval && ! valid_number? ( request_time_interval ) ) logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: REQUEST_TIME_INTERVAL_INVALID , file : VWO :: FileNameEnum :: ValidateUtil ) ) return false end if ( events_per_request && ! valid_number? ( events_per_request ) ) logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: EVENTS_PER_REQUEST_INVALID , file : VWO :: FileNameEnum :: ValidateUtil ) ) return false end if events_per_request && ( events_per_request < VWO :: MIN_EVENTS_PER_REQUEST || events_per_request > VWO :: MAX_EVENTS_PER_REQUEST ) logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: EVENTS_PER_REQUEST_OUT_OF_BOUNDS , file : VWO :: FileNameEnum :: ValidateUtil , min_value : VWO :: MIN_EVENTS_PER_REQUEST , max_value : VWO :: MAX_EVENTS_PER_REQUEST ) ) return false end if request_time_interval && request_time_interval < VWO :: MIN_REQUEST_TIME_INTERVAL logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: REQUEST_TIME_INTERVAL_OUT_OF_BOUNDS , file : VWO :: FileNameEnum :: ValidateUtil , min_value : VWO :: MIN_REQUEST_TIME_INTERVAL ) ) return false end if batch_events . key? ( :flushCallback ) && ! batch_events [ :flushCallback ] . is_a? ( Method ) logger . log ( VWO :: LogLevelEnum :: ERROR , format ( VWO :: LogMessageEnum :: ErrorMessages :: FLUSH_CALLBACK_INVALID , file : VWO :: FileNameEnum :: ValidateUtil ) ) return false end true end
Validates if the value passed batch_events has correct data type and values or not.
Validates if the value passed batch_events has correct data type and values or not .
batch_events
<not_specific>
return:
[Boolean]: True if all conditions are passed else False
[ Boolean ] : True if all conditions are passed else False