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



71
72
73
74
75
76
77
78
# File 'lib/subvalid/validator.rb', line 71

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