Add length facets to XSD.AnyURI
This commit is contained in:
parent
dbaac77dbb
commit
80b1382fa9
2 changed files with 34 additions and 3 deletions
|
@ -7,13 +7,34 @@ defmodule RDF.XSD.AnyURI do
|
||||||
|
|
||||||
@type valid_value :: URI.t()
|
@type valid_value :: URI.t()
|
||||||
|
|
||||||
|
use RDF.XSD.Datatype.Primitive,
|
||||||
|
name: "anyURI",
|
||||||
|
id: RDF.Utils.Bootstrapping.xsd_iri("anyURI")
|
||||||
|
|
||||||
alias RDF.{IRI, XSD}
|
alias RDF.{IRI, XSD}
|
||||||
|
|
||||||
import RDF.Guards
|
import RDF.Guards
|
||||||
|
|
||||||
use XSD.Datatype.Primitive,
|
|
||||||
name: "anyURI",
|
def_applicable_facet XSD.Facets.MinLength
|
||||||
id: RDF.Utils.Bootstrapping.xsd_iri("anyURI")
|
def_applicable_facet XSD.Facets.MaxLength
|
||||||
|
def_applicable_facet XSD.Facets.Length
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def min_length_conform?(min_length, _value, lexical) do
|
||||||
|
String.length(lexical) >= min_length
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def max_length_conform?(max_length, _value, lexical) do
|
||||||
|
String.length(lexical) <= max_length
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def length_conform?(length, _value, lexical) do
|
||||||
|
String.length(lexical) == length
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@impl XSD.Datatype
|
@impl XSD.Datatype
|
||||||
@spec lexical_mapping(String.t(), Keyword.t()) :: valid_value
|
@spec lexical_mapping(String.t(), Keyword.t()) :: valid_value
|
||||||
|
|
|
@ -3,6 +3,16 @@ defmodule RDF.XSD.AnyURITest do
|
||||||
datatype: RDF.XSD.AnyURI,
|
datatype: RDF.XSD.AnyURI,
|
||||||
name: "anyURI",
|
name: "anyURI",
|
||||||
primitive: true,
|
primitive: true,
|
||||||
|
applicable_facets: [
|
||||||
|
RDF.XSD.Facets.MinLength,
|
||||||
|
RDF.XSD.Facets.MaxLength,
|
||||||
|
RDF.XSD.Facets.Length,
|
||||||
|
],
|
||||||
|
facets: %{
|
||||||
|
max_length: nil,
|
||||||
|
min_length: nil,
|
||||||
|
length: nil,
|
||||||
|
},
|
||||||
valid: %{
|
valid: %{
|
||||||
# input => { value, lexical, canonicalized }
|
# input => { value, lexical, canonicalized }
|
||||||
"http://example.com/foo" =>
|
"http://example.com/foo" =>
|
||||||
|
|
Loading…
Reference in a new issue