defmodule NLdoc.Spec.Validation do @moduledoc """ This module defines the Ecto schema for the NLdoc Validation spec Validation object. """ use NLdoc.Spec.Schema, type: "https://spec.validation.nldoc.nl/Resource/Validation" @doc """ Returns the version of the NLdoc Validation spec that the `NLdoc.Spec` library implements. """ @version "2.0.0" @spec version() :: String.t() def version, do: @version typed_embedded_schema null: false do field :type, :string, default: @resource_type field :resource_id, Ecto.UUID field :severity, Ecto.Enum, values: [:error, :warning, :notice] field :rule, :string field :ruleset, :string field :ruleset_version, :string end def changeset(object, attrs) do fields = [:type, :resource_id, :severity, :rule, :ruleset, :ruleset_version] object |> cast(attrs, fields, @cast_opts) |> validate_required(fields) |> validate_inclusion(:type, [@resource_type]) |> validate_url(:ruleset) end end