Class: FeatureFlagStrategiesValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/feature_flag_strategies_validator.rb

Constant Summary collapse

STRATEGY_DEFAULT =
'default'
STRATEGY_GRADUALROLLOUTUSERID =
'gradualRolloutUserId'
STRATEGY_USERWITHID =
'userWithId'
STRATEGIES =

Order key names alphabetically

{
  STRATEGY_DEFAULT => [].freeze,
  STRATEGY_GRADUALROLLOUTUSERID => %w[groupId percentage].freeze,
  STRATEGY_USERWITHID => ['userIds'].freeze
}.freeze
USERID_MAX_LENGTH =
256

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'app/validators/feature_flag_strategies_validator.rb', line 15

def validate_each(record, attribute, value)
  return unless value

  if value.is_a?(Array) && value.all?(Hash)
    value.each do |strategy|
      strategy_validations(record, attribute, strategy)
    end
  else
    error(record, attribute, 'must be an array of strategy hashes')
  end
end