Class: Lutaml::Xsd::Validation::Facets::MinExclusiveFacetValidator

Inherits:
FacetValidator
  • Object
show all
Defined in:
lib/lutaml/xsd/validation/facets/min_exclusive_facet_validator.rb

Overview

Validates values against XSD minExclusive facet

The minExclusive facet specifies the minimum value (exclusive) for numeric types.

Examples:

Validating minimum exclusive

facet = Lutaml::Xsd::MinExclusive.new(value: "10")
validator = MinExclusiveFacetValidator.new(facet)
validator.valid?("10")  # => false (10 == 10)
validator.valid?("11")  # => true (11 > 10)
validator.valid?("5")   # => false (5 < 10)
validator.error_message("5")
# => "Value 5 is not greater than minimum exclusive value 10"

Instance Attribute Summary

Attributes inherited from FacetValidator

#facet

Instance Method Summary collapse

Methods inherited from FacetValidator

#facet_value, #initialize

Constructor Details

This class inherits a constructor from Lutaml::Xsd::Validation::Facets::FacetValidator

Instance Method Details

#error_message(value) ⇒ String

Generate error message for minimum exclusive violation

Parameters:

  • value (String, Numeric)

    The invalid value

Returns:

  • (String)

    Error message describing the violation



43
44
45
46
# File 'lib/lutaml/xsd/validation/facets/min_exclusive_facet_validator.rb', line 43

def error_message(value)
  "Value #{value} is not greater than minimum exclusive value " \
    "#{facet_value}"
end

#valid?(value) ⇒ Boolean

Validate value is > minimum

Parameters:

  • value (String, Numeric)

    The value to validate

Returns:

  • (Boolean)

    true if value > minimum, false otherwise



28
29
30
31
32
33
34
35
36
37
# File 'lib/lutaml/xsd/validation/facets/min_exclusive_facet_validator.rb', line 28

def valid?(value)
  return false if value.nil?

  numeric_value = to_numeric(value)
  min_value = to_numeric(facet_value)

  return false unless numeric_value && min_value

  numeric_value > min_value
end