Class: Respect::AnySchema
Instance Attribute Summary
Attributes inherited from Schema
#last_error, #options, #sanitized_object
Instance Method Summary (collapse)
Methods inherited from Schema
#==, #allow_nil?, def_class, def_class_name, #default, default_options, define, #documentation, #documented?, #has_default?, #initialize, #initialize_copy, #inspect, #non_default_options, #optional?, #required?, #sanitize!, #sanitize_object!, statement_name, #to_h, #to_json, #to_s, #validate!, #validate?
Methods included from DocHelper
Constructor Details
This class inherits a constructor from Respect::Schema
Instance Method Details
- (Object) validate(object)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/respect/any_schema.rb', line 6 def validate(object) case object when Hash, Array, TrueClass, FalseClass, Numeric, NilClass, String self.sanitized_object = object true else raise ValidationError, "object is not of a valid type but a #{object.class}" end rescue ValidationError => e # Reset sanitized object. self.sanitized_object = nil raise e end |