Class: Subvalid::Validator::BlockValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/subvalid/validator.rb

Defined Under Namespace

Classes: Context

Class Method Summary collapse

Class Method Details

.validate(object, validation_result = ValidationResult.new, *args) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/subvalid/validator.rb', line 85

def self.validate(object, validation_result=ValidationResult.new, *args)
  #return unless object # don't pass nil object into block - this should be handled with a PresenceValidator if it needs to be flagged as a validation error
  block = args[0]

  context = Context.new
  context.instance_exec(&block)
  context.validate(object, validation_result, args)
end