Class: Lutaml::Xsd::Validation::Facets::FacetValidator Abstract
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Validation::Facets::FacetValidator
- Defined in:
- lib/lutaml/xsd/validation/facets/facet_validator.rb
Overview
Subclasses must implement #valid? and #error_message
Base class for all facet validators
Facet validators validate values against specific XSD facet constraints such as pattern, length, min/max values, etc.
Direct Known Subclasses
EnumerationFacetValidator, FractionDigitsFacetValidator, LengthFacetValidator, MaxExclusiveFacetValidator, MaxInclusiveFacetValidator, MaxLengthFacetValidator, MinExclusiveFacetValidator, MinInclusiveFacetValidator, MinLengthFacetValidator, PatternFacetValidator, TotalDigitsFacetValidator, WhiteSpaceFacetValidator
Instance Attribute Summary collapse
-
#facet ⇒ Object
readonly
Returns the value of attribute facet.
Instance Method Summary collapse
-
#error_message(value) ⇒ String
abstract
Generate an error message for an invalid value.
-
#facet_value ⇒ Object
Get the facet value.
-
#initialize(facet) ⇒ FacetValidator
constructor
Initialize the facet validator.
-
#valid?(value) ⇒ Boolean
abstract
Validate a value against the facet constraint.
Constructor Details
#initialize(facet) ⇒ FacetValidator
Initialize the facet validator
33 34 35 |
# File 'lib/lutaml/xsd/validation/facets/facet_validator.rb', line 33 def initialize(facet) @facet = facet end |
Instance Attribute Details
#facet ⇒ Object (readonly)
Returns the value of attribute facet.
27 28 29 |
# File 'lib/lutaml/xsd/validation/facets/facet_validator.rb', line 27 def facet @facet end |
Instance Method Details
#error_message(value) ⇒ String
Subclasses must implement this method
Generate an error message for an invalid value
54 55 56 57 |
# File 'lib/lutaml/xsd/validation/facets/facet_validator.rb', line 54 def (value) raise NotImplementedError, "#{self.class.name} must implement #error_message" end |
#facet_value ⇒ Object
Get the facet value
62 63 64 |
# File 'lib/lutaml/xsd/validation/facets/facet_validator.rb', line 62 def facet_value facet.value if facet.respond_to?(:value) end |
#valid?(value) ⇒ Boolean
Subclasses must implement this method
Validate a value against the facet constraint
43 44 45 46 |
# File 'lib/lutaml/xsd/validation/facets/facet_validator.rb', line 43 def valid?(value) raise NotImplementedError, "#{self.class.name} must implement #valid?" end |