Class: Lutaml::Xsd::Validation::BaseTypes::BaseTypeValidator Abstract
- Inherits:
-
Object
- Object
- Lutaml::Xsd::Validation::BaseTypes::BaseTypeValidator
- Defined in:
- lib/lutaml/xsd/validation/base_types/base_type_validator.rb
Overview
Subclasses must implement #valid? and #error_message
Base class for all XSD built-in type validators
Base type validators validate values against XSD built-in types like string, integer, boolean, dateTime, etc.
Direct Known Subclasses
AnyURIValidator, BooleanValidator, DateTimeValidator, DateValidator, DecimalValidator, IntegerValidator, QNameValidator, StringValidator, TimeValidator
Class Method Summary collapse
-
.for(type_name) ⇒ BaseTypeValidator
Get validator for a specific XSD type name.
-
.registered?(type_name) ⇒ Boolean
Check if a type is registered.
Instance Method Summary collapse
-
#error_message(value) ⇒ String
abstract
Generate an error message for an invalid value.
-
#type_name ⇒ String
Get the type name.
-
#valid?(value) ⇒ Boolean
abstract
Validate a value against the type.
Class Method Details
.for(type_name) ⇒ BaseTypeValidator
Get validator for a specific XSD type name
66 67 68 69 70 71 |
# File 'lib/lutaml/xsd/validation/base_types/base_type_validator.rb', line 66 def for(type_name) # Load registry on first access require_relative "base_type_validator_registry" unless defined?(BaseTypeValidatorRegistry) BaseTypeValidatorRegistry.validator_for(type_name) end |
.registered?(type_name) ⇒ Boolean
Check if a type is registered
77 78 79 80 81 |
# File 'lib/lutaml/xsd/validation/base_types/base_type_validator.rb', line 77 def registered?(type_name) require_relative "base_type_validator_registry" unless defined?(BaseTypeValidatorRegistry) BaseTypeValidatorRegistry.registered?(type_name) end |
Instance Method Details
#error_message(value) ⇒ String
Subclasses must implement this method
Generate an error message for an invalid value
48 49 50 51 |
# File 'lib/lutaml/xsd/validation/base_types/base_type_validator.rb', line 48 def (value) raise NotImplementedError, "#{self.class.name} must implement #error_message" end |
#type_name ⇒ String
Get the type name
56 57 58 |
# File 'lib/lutaml/xsd/validation/base_types/base_type_validator.rb', line 56 def type_name self.class.name.split("::").last.sub(/Validator$/, "") end |
#valid?(value) ⇒ Boolean
Subclasses must implement this method
Validate a value against the type
37 38 39 40 |
# File 'lib/lutaml/xsd/validation/base_types/base_type_validator.rb', line 37 def valid?(value) raise NotImplementedError, "#{self.class.name} must implement #valid?" end |