Class: IncludedInValidation

Inherits:
Validation show all
Defined in:
lib/yodel/models/core/validations/included_in_validation.rb

Instance Attribute Summary

Attributes inherited from Validation

#field, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Validation

#initialize, #to_json

Constructor Details

This class inherits a constructor from Validation

Class Method Details

.validate(params, field, name, value, record, errors) ⇒ Object



2
3
4
5
# File 'lib/yodel/models/core/validations/included_in_validation.rb', line 2

def self.validate(params, field, name, value, record, errors)
  valid_values = params['valid_values']
  errors[field.name] << new(valid_values) unless valid_values.include?(value)
end

Instance Method Details

#describeObject



7
8
9
# File 'lib/yodel/models/core/validations/included_in_validation.rb', line 7

def describe
  "must be one of: #{params.join(', ')}"
end