Class: DataMapper::Validate::PrimitiveValidator
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- DataMapper::Validate::PrimitiveValidator
- Defined in:
- lib/gems/dm-validations-0.9.9/lib/dm-validations/primitive_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from GenericValidator
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(field_name, options = {}) ⇒ PrimitiveValidator
constructor
A new instance of PrimitiveValidator.
Methods inherited from GenericValidator
#==, #add_error, #execute?, #field_name
Constructor Details
#initialize(field_name, options = {}) ⇒ PrimitiveValidator
Returns a new instance of PrimitiveValidator.
10 11 12 13 |
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/primitive_validator.rb', line 10 def initialize(field_name, ={}) super @field_name, @options = field_name, end |
Instance Method Details
#call(target) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/primitive_validator.rb', line 15 def call(target) value = target.validation_property_value(@field_name) property = target.validation_property(@field_name) return true if value.nil? || value.kind_of?(property.primitive) || property.primitive == TrueClass && value.kind_of?(FalseClass) = @options[:message] || default_error(property) add_error(target, , @field_name) false end |