Class: CouchRest::Validation::AbsentFieldValidator
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- CouchRest::Validation::AbsentFieldValidator
- Defined in:
- lib/couchrest/validation/validators/absent_field_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from GenericValidator
#field_name, #if_clause, #unless_clause
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(field_name, options = {}) ⇒ AbsentFieldValidator
constructor
A new instance of AbsentFieldValidator.
Methods inherited from GenericValidator
Constructor Details
#initialize(field_name, options = {}) ⇒ AbsentFieldValidator
Returns a new instance of AbsentFieldValidator.
32 33 34 35 |
# File 'lib/couchrest/validation/validators/absent_field_validator.rb', line 32 def initialize(field_name, ={}) super @field_name, @options = field_name, end |
Instance Method Details
#call(target) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/couchrest/validation/validators/absent_field_validator.rb', line 37 def call(target) value = target.send(field_name) return true if (value.nil? || (value.respond_to?(:empty?) && value.empty?)) = @options[:message] || ValidationErrors.(:absent, field_name) add_error(target, , field_name) return false end |