Exception: Async::Matrix::Schema::ValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/async/matrix/schema/validation_error.rb

Overview

Raised by Event#valid! when data fails schema validation.

Produces detailed, human-readable error messages that identify the exact key path and offending value.

Schema validation failed for m.room.member event $abc123:
  - content.membership = "invalid" -- must be one of: ["invite", "join", "knock", "leave", "ban"]
  - sender is required but missing

Instance Attribute Summary collapse

Attributes inherited from Error

#errcode, #status

Instance Method Summary collapse

Constructor Details

#initialize(errors, event_type: nil, event_id: nil) ⇒ ValidationError

Returns a new instance of ValidationError.

Parameters:

  • errors (Array<Hash>)

    raw JSONSchemer error hashes

  • event_type (String, nil) (defaults to: nil)

    Matrix event type (e.g. “m.room.member”)

  • event_id (String, nil) (defaults to: nil)

    Matrix event ID (e.g. “$abc123”)



26
27
28
29
30
31
# File 'lib/async/matrix/schema/validation_error.rb', line 26

def initialize(errors, event_type: nil, event_id: nil)
	@errors     = errors
	@event_type = event_type
	@event_id   = event_id
	super("M_BAD_JSON", build_message)
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



21
22
23
# File 'lib/async/matrix/schema/validation_error.rb', line 21

def errors
  @errors
end

#event_idObject (readonly)

Returns the value of attribute event_id.



21
22
23
# File 'lib/async/matrix/schema/validation_error.rb', line 21

def event_id
  @event_id
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



21
22
23
# File 'lib/async/matrix/schema/validation_error.rb', line 21

def event_type
  @event_type
end