Class: Lutaml::Xsd::Validation::Facets::MinLengthFacetValidator
- Inherits:
-
FacetValidator
- Object
- FacetValidator
- Lutaml::Xsd::Validation::Facets::MinLengthFacetValidator
- Defined in:
- lib/lutaml/xsd/validation/facets/min_length_facet_validator.rb
Overview
Validates values against XSD minLength facet
The minLength facet specifies the minimum length of a value. For strings, it’s the minimum number of characters. For lists, it’s the minimum number of items.
Instance Attribute Summary
Attributes inherited from FacetValidator
Instance Method Summary collapse
-
#error_message(value) ⇒ String
Generate error message for minimum length violation.
-
#valid?(value) ⇒ Boolean
Validate value meets minimum length.
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 minimum length violation
41 42 43 44 45 |
# File 'lib/lutaml/xsd/validation/facets/min_length_facet_validator.rb', line 41 def (value) actual_length = value.nil? ? 0 : to_string(value).length "Value length #{actual_length} is less than minimum " \ "length #{facet_value}" end |
#valid?(value) ⇒ Boolean
Validate value meets minimum length
28 29 30 31 32 33 34 35 |
# File 'lib/lutaml/xsd/validation/facets/min_length_facet_validator.rb', line 28 def valid?(value) return false if value.nil? min_length = to_integer(facet_value) return false unless min_length to_string(value).length >= min_length end |