defmodule NLdoc.Spec.StringDescriptor do @moduledoc """ This module defines the Ecto schema for the NLdoc spec StringDescriptor object. """ use NLdoc.Spec.Schema, type: "https://spec.nldoc.nl/Resource/StringDescriptor" typed_embedded_schema null: false do field :type, :string, default: @resource_type field :uri, :string field :value, :string, null: true end @spec changeset(struct(), map()) :: Ecto.Changeset.t() def changeset(descriptor, attrs) do descriptor |> cast(attrs, [:type, :uri, :value], @cast_opts) |> validate_required([:type, :uri]) |> validate_inclusion(:type, [@resource_type]) |> validate_url(:uri) end end