Class: Lutaml::Xsd::Validation::Facets::WhiteSpaceFacetValidator
- Inherits:
-
FacetValidator
- Object
- FacetValidator
- Lutaml::Xsd::Validation::Facets::WhiteSpaceFacetValidator
- Defined in:
- lib/lutaml/xsd/validation/facets/white_space_facet_validator.rb
Overview
Validates and normalizes values against XSD whiteSpace facet
The whiteSpace facet specifies how whitespace should be handled:
-
preserve: All whitespace is preserved
-
replace: Each tab, newline, and carriage return is replaced with a space
-
collapse: Sequences of whitespace are collapsed to a single space, and leading/trailing whitespace is removed
Constant Summary collapse
- PRESERVE =
"preserve"- REPLACE =
"replace"- COLLAPSE =
"collapse"
Instance Attribute Summary
Attributes inherited from FacetValidator
Instance Method Summary collapse
-
#error_message(value) ⇒ String
Generate error message (not typically used for whiteSpace).
-
#normalize(value) ⇒ String
Normalize value according to whiteSpace facet.
-
#valid?(_value) ⇒ Boolean
Validate always returns true as whiteSpace is about normalization.
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 (not typically used for whiteSpace)
42 43 44 |
# File 'lib/lutaml/xsd/validation/facets/white_space_facet_validator.rb', line 42 def (value) "Invalid whitespace handling for value: #{value}" end |
#normalize(value) ⇒ String
Normalize value according to whiteSpace facet
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/lutaml/xsd/validation/facets/white_space_facet_validator.rb', line 50 def normalize(value) return value if value.nil? case facet_value when PRESERVE value when REPLACE replace_whitespace(value) when COLLAPSE collapse_whitespace(value) else value end end |
#valid?(_value) ⇒ Boolean
Validate always returns true as whiteSpace is about normalization
34 35 36 |
# File 'lib/lutaml/xsd/validation/facets/white_space_facet_validator.rb', line 34 def valid?(_value) true end |