Class: Varify::Rules::IsARule

Inherits:
Rule
  • Object
show all
Defined in:
lib/varify/rules/is_a.rb

Instance Method Summary collapse

Methods inherited from Rule

#initialize

Constructor Details

This class inherits a constructor from Varify::Rules::Rule

Instance Method Details

#error_messageObject



14
15
16
# File 'lib/varify/rules/is_a.rb', line 14

def error_message
  "#{@name} (:#{@key}) must be a #{@options.name}"
end

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
# File 'lib/varify/rules/is_a.rb', line 6

def valid?
  if @options.is_a?(Array)
    @values.all?{|i| i.is_a?(@options.first)}
  else
    @value.is_a?(@options)
  end
end