Class: Seedie::FieldValues::ValueTemplateValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/seedie/field_values/value_template_validator.rb

Constant Summary collapse

VALID_KEYS =
%w[values value options].freeze
PICK_STRATEGIES =
%w[random sequential].freeze

Instance Method Summary collapse

Constructor Details

#initialize(value_template, index, name) ⇒ ValueTemplateValidator

Returns a new instance of ValueTemplateValidator.



9
10
11
12
13
# File 'lib/seedie/field_values/value_template_validator.rb', line 9

def initialize(value_template, index, name)
  @value_template = value_template
  @index = index
  @name = name
end

Instance Method Details

#validateObject



15
16
17
18
19
20
21
# File 'lib/seedie/field_values/value_template_validator.rb', line 15

def validate
  return unless @value_template.is_a?(Hash)

  validate_keys
  validate_values if @value_template.key?("values")
  validate_options if @value_template.key?("options")
end