Class: Varify::Rules::IsARule
- Inherits:
-
Rule
- Object
- Rule
- Varify::Rules::IsARule
show all
- Defined in:
- lib/varify/rules/is_a.rb
Instance Method Summary
collapse
Methods inherited from Rule
#initialize
Instance Method Details
#error_message ⇒ Object
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
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
|