Class: Compel::Validation::Is

Inherits:
Condition show all
Defined in:
lib/compel/validation/conditions/is.rb

Instance Attribute Summary

Attributes inherited from Condition

#options, #value, #value_type

Instance Method Summary collapse

Methods inherited from Condition

#initialize, validate, #validate

Constructor Details

This class inherits a constructor from Compel::Validation::Condition

Instance Method Details

#option_valueObject



6
7
8
9
10
11
12
# File 'lib/compel/validation/conditions/is.rb', line 6

def option_value
  if value_type == Coercion::Hash
    return @option_value.to_hash
  end

  @option_value
end

#validate_valueObject



14
15
16
17
18
# File 'lib/compel/validation/conditions/is.rb', line 14

def validate_value
  unless valid?
    "must be #{option_value}"
  end
end