Class: ExcludedFromValidation

Inherits:
Validation show all
Defined in:
lib/yodel/models/core/validations/excluded_from_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/excluded_from_validation.rb', line 2

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

Instance Method Details

#describeObject



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

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