defmodule NLdoc.Spec.IntegerDescriptor do @moduledoc """ This module defines the Ecto schema for the NLdoc spec IntegerDescriptor object. """ use NLdoc.Spec.Schema, type: "https://spec.nldoc.nl/Resource/IntegerDescriptor" typed_embedded_schema null: false do field :type, :string, default: @resource_type field :uri, :string field :value, :integer, null: true end 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