Restore casting of IRIs to strings
This commit is contained in:
parent
d324b464b2
commit
2b46bb8f23
2 changed files with 6 additions and 0 deletions
|
@ -21,6 +21,8 @@ defmodule RDF.XSD.String do
|
|||
@impl RDF.Literal.Datatype
|
||||
def do_cast(value)
|
||||
|
||||
def do_cast(%RDF.IRI{value: value}), do: new(value)
|
||||
|
||||
def do_cast(%RDF.XSD.Decimal{} = xsd_decimal) do
|
||||
try do
|
||||
xsd_decimal.value
|
||||
|
|
|
@ -109,6 +109,10 @@ defmodule RDF.XSD.StringTest do
|
|||
assert XSD.time("00:00:00+01:00") |> XSD.String.cast() == XSD.string("00:00:00+01:00")
|
||||
end
|
||||
|
||||
test "casting an IRI" do
|
||||
assert RDF.iri("http://example.com") |> XSD.String.cast() == XSD.string("http://example.com")
|
||||
end
|
||||
|
||||
test "with invalid literals" do
|
||||
assert XSD.integer(3.14) |> XSD.String.cast() == nil
|
||||
assert XSD.decimal("NAN") |> XSD.String.cast() == nil
|
||||
|
|
Loading…
Reference in a new issue