Class: Metaschema::ConstraintValidator::ConstraintError

Inherits:
Object
  • Object
show all
Defined in:
lib/metaschema/constraint_validator.rb

Overview

Simple wrapper for constraint error info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constraint_type:, level:, message:, target:) ⇒ ConstraintError

Returns a new instance of ConstraintError.



463
464
465
466
467
468
# File 'lib/metaschema/constraint_validator.rb', line 463

def initialize(constraint_type:, level:, message:, target:)
  @constraint_type = constraint_type
  @level = level
  @message = message
  @target = target
end

Instance Attribute Details

#constraint_typeObject (readonly)

Returns the value of attribute constraint_type.



461
462
463
# File 'lib/metaschema/constraint_validator.rb', line 461

def constraint_type
  @constraint_type
end

#levelObject (readonly)

Returns the value of attribute level.



461
462
463
# File 'lib/metaschema/constraint_validator.rb', line 461

def level
  @level
end

#messageObject (readonly)

Returns the value of attribute message.



461
462
463
# File 'lib/metaschema/constraint_validator.rb', line 461

def message
  @message
end

#targetObject (readonly)

Returns the value of attribute target.



461
462
463
# File 'lib/metaschema/constraint_validator.rb', line 461

def target
  @target
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


474
475
476
# File 'lib/metaschema/constraint_validator.rb', line 474

def error?
  level == "ERROR"
end

#to_sObject



470
471
472
# File 'lib/metaschema/constraint_validator.rb', line 470

def to_s
  "[#{level}] #{constraint_type}: #{message} (target: #{target})"
end

#warning?Boolean

Returns:

  • (Boolean)


478
479
480
# File 'lib/metaschema/constraint_validator.rb', line 478

def warning?
  level == "WARNING"
end