class Hermod::Validators::AllowedValues

Checks the given value is in a predefined list of allowed values

def initialize(allowed_values)

Sets up the validator with the list of allowed values
def initialize(allowed_values)
  @allowed_values = allowed_values
end

def message(value, attributes)

def message(value, attributes)
  list_of_values = allowed_values.to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
  "must be one of #{list_of_values}, not #{value}"
end

def test(value, attributes)

def test(value, attributes)
  value.blank? || allowed_values.include?(value)
end