Class: Lutaml::Xsd::Validation::BaseTypes::AnyURIValidator
- Inherits:
-
BaseTypeValidator
- Object
- BaseTypeValidator
- Lutaml::Xsd::Validation::BaseTypes::AnyURIValidator
- Defined in:
- lib/lutaml/xsd/validation/base_types/any_uri_validator.rb
Overview
Validates XSD anyURI type
The anyURI type represents a Uniform Resource Identifier (URI) reference. This includes URLs, URNs, and relative URIs.
Instance Method Summary collapse
-
#error_message(value) ⇒ String
Generate error message for invalid URI.
-
#valid?(value) ⇒ Boolean
Validate value is a valid URI.
Methods inherited from BaseTypeValidator
Instance Method Details
#error_message(value) ⇒ String
Generate error message for invalid URI
47 48 49 |
# File 'lib/lutaml/xsd/validation/base_types/any_uri_validator.rb', line 47 def (value) "Value '#{value}' is not a valid URI" end |
#valid?(value) ⇒ Boolean
Validate value is a valid URI
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lutaml/xsd/validation/base_types/any_uri_validator.rb', line 29 def valid?(value) return false if value.nil? return true if value.is_a?(URI) str = to_string(value).strip return false if str.empty? # Try to parse as URI URI.parse(str) true rescue URI::InvalidURIError false end |