Class: Waw::Validation::SameValidator

Inherits:
Validator show all
Defined in:
lib/waw/validation/same_validator.rb

Overview

Checks that arguments are all non missing and equal

Instance Method Summary collapse

Methods inherited from Validator

#&, #===, #=~, #initialize, #not, #|

Methods included from Helpers

#all_missing?, #any_missing?, #argument_safe, #error, #is_missing?, #missings_to_nil, #no_missing?, #to_validator

Constructor Details

This class inherits a constructor from Waw::Validation::Validator

Instance Method Details

#convert_and_validate(*values) ⇒ Object



10
11
12
# File 'lib/waw/validation/same_validator.rb', line 10

def convert_and_validate(*values)
  [validate(*values), values]
end

#validate(*values) ⇒ Object



6
7
8
# File 'lib/waw/validation/same_validator.rb', line 6

def validate(*values)
  any_missing?(values) ? false : values.uniq.size==1
end