Module: RSAML::Validatable

Included in:
Action, Advice, Assertion, AssertionIDRef, AssertionURIRef
Defined in:
lib/rsaml/validatable.rb

Overview

Module that can be mixed in to any class to provide a :valid? method. This method will look for a :validate method and invoke it, catching any ValidationError exceptions and return either true if the SAML object is structurally valid or false if it isn’t.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/rsaml/validatable.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#valid?Boolean

Return true if the object is valid. Only objects with a validate method will be checked for validity.

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rsaml/validatable.rb', line 9

def valid?
  if respond_to?(:validate)
    begin
      validate
    rescue ValidationError => e
      puts "Validation failed: #{e.message}" if verbose
      return false
    end
  end
  return true
end