Class: Isomorfeus::Props::Validator

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

Instance Method Summary collapse

Constructor Details

#initialize(source_class, prop, value, options) ⇒ Validator

Returns a new instance of Validator.



4
5
6
7
8
9
# File 'lib/isomorfeus/props/validator.rb', line 4

def initialize(source_class, prop, value, options)
  @c = source_class
  @p = prop
  @v = value
  @o = options
end

Instance Method Details

#validate!Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/isomorfeus/props/validator.rb', line 11

def validate!
  ensured = ensure!
  unless ensured
    set_default_value
    cast!
    type!
  end
  run_checks!
  true
end

#validated_valueObject



22
23
24
25
# File 'lib/isomorfeus/props/validator.rb', line 22

def validated_value
  validate!
  @v
end