Class: Lutaml::Xml::Schema::Xsd::ValidationError

Inherits:
Model::Serializable show all
Defined in:
lib/lutaml/xml/schema/xsd/validation_error.rb

Overview

Represents a single validation error with structured information

Constant Summary

Constants included from Model::Serialize

Model::Serialize::DEFAULT_VALUE_MAP, Model::Serialize::INTERNAL_ATTRIBUTES, Model::Serialize::LAZY_EMPTY_COLLECTION

Instance Attribute Summary

Attributes included from Model::Serialize

#lutaml_parent, #lutaml_register, #lutaml_root

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::Serialize

#attr_value, #attribute_exist?, #extract_register_id, included, #init_deserialization_state, #initialize, #key_exist?, #key_value, #method_missing, #prepare_instance_format_options, #pretty_print_instance_variables, register_format_mapping_method, register_from_format_method, register_to_format_method, #respond_to_missing?, #to_format, #to_yaml_hash, #using_default?, #using_default_for, #validate_attribute!, #validate_root_mapping!, #value_map, #value_set_for

Methods included from Model::Liquefiable

included, #to_liquid

Methods included from Model::Validation

#format_element_sequences, #order_names, #validate, #validate!, #validate_helper, #validate_sequence!

Methods included from Model::ComparableModel

#already_compared?, #attributes_hash, #calculate_hash, #comparison_key, #eql?, #hash, included, #same_class?

Methods included from Model::Serialize::Builder

#initialize, #mixed_content?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lutaml::Model::Serialize

Class Method Details

.create(field:, message:, value: nil, constraint: nil) ⇒ ValidationError

Factory method for creating validation errors with type conversion

Parameters:

  • field (Symbol, String)

    The field that failed validation

  • message (String)

    Human-readable error message

  • value (Object) (defaults to: nil)

    The actual value that was invalid (optional)

  • constraint (String) (defaults to: nil)

    The constraint that was violated (optional)

Returns:



27
28
29
30
31
32
33
34
# File 'lib/lutaml/xml/schema/xsd/validation_error.rb', line 27

def self.create(field:, message:, value: nil, constraint: nil)
  new(
    field: field.to_s,
    message: message,
    value: value&.to_s,
    constraint: constraint,
  )
end

Instance Method Details

#to_sString

Format as human-readable string

Returns:

  • (String)


38
39
40
41
42
43
# File 'lib/lutaml/xml/schema/xsd/validation_error.rb', line 38

def to_s
  parts = ["#{field}: #{message}"]
  parts << "(value: #{value})" if value
  parts << "[constraint: #{constraint}]" if constraint
  parts.join(" ")
end