Class: Perpetuity::ValidationSet

Inherits:
Set
  • Object
show all
Defined in:
lib/perpetuity/validations/validation_set.rb

Instance Method Summary collapse

Instance Method Details

#invalid?(object) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/perpetuity/validations/validation_set.rb', line 16

def invalid? object
  !valid? object
end

#length(attribute, options = {}) ⇒ Object



24
25
26
# File 'lib/perpetuity/validations/validation_set.rb', line 24

def length attribute, options = {}
  self << Perpetuity::Validations::Length.new(attribute, options)
end

#present(attribute) ⇒ Object



20
21
22
# File 'lib/perpetuity/validations/validation_set.rb', line 20

def present attribute
  self << Perpetuity::Validations::Presence.new(attribute)
end

#valid?(object) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
# File 'lib/perpetuity/validations/validation_set.rb', line 8

def valid? object
  each do |validation|
    return false unless validation.pass?(object)
  end

  true
end