Class: Lutaml::Xsd::Validation::Facets::TotalDigitsFacetValidator
- Inherits:
-
FacetValidator
- Object
- FacetValidator
- Lutaml::Xsd::Validation::Facets::TotalDigitsFacetValidator
- Defined in:
- lib/lutaml/xsd/validation/facets/total_digits_facet_validator.rb
Overview
Validates values against XSD totalDigits facet
The totalDigits facet specifies the maximum number of digits (excluding leading zeros, trailing zeros after decimal point, and decimal point itself) for decimal and integer types.
Instance Attribute Summary
Attributes inherited from FacetValidator
Instance Method Summary collapse
-
#error_message(value) ⇒ String
Generate error message for total digits violation.
-
#valid?(value) ⇒ Boolean
Validate value has correct total digits.
Methods inherited from FacetValidator
Constructor Details
This class inherits a constructor from Lutaml::Xsd::Validation::Facets::FacetValidator
Instance Method Details
#error_message(value) ⇒ String
Generate error message for total digits violation
43 44 45 46 47 |
# File 'lib/lutaml/xsd/validation/facets/total_digits_facet_validator.rb', line 43 def (value) actual_digits = count_digits(value) "Value has #{actual_digits} digits, exceeds maximum of " \ "#{facet_value} total digits" end |
#valid?(value) ⇒ Boolean
Validate value has correct total digits
30 31 32 33 34 35 36 37 |
# File 'lib/lutaml/xsd/validation/facets/total_digits_facet_validator.rb', line 30 def valid?(value) return false if value.nil? max_digits = to_integer(facet_value) return false unless max_digits count_digits(value) <= max_digits end |