NativeElixirPdfUtilities.Validators.ObjectValidator (native_elixir_pdf_utilities v1.1.0)

View Source

Validation and selection of local object and embedded-document sources.

The selected-source types describe the values consumed by the embedded viewport pipeline. Resource authorization remains in the owning resource validator.

Summary

Functions

Authorizes a selected local object/embed resource without inline document descriptors.

Normalizes the supported selected-file MIME vocabulary before reads.

Validates a selected dispatch plan and its host before any file work.

Selects static fallback, blank initialization, an empty embed or a supported local resource before lookup.

Checks selected resource content against file MIME evidence before decoding.

Types

selected()

@type selected() ::
  :fallback
  | :empty
  | :blank
  | {:blank, String.t()}
  | {:document, String.t(), String.t()}
  | {:image, String.t(), String.t()}

Functions

authorize_html(source, context, opts)

Authorizes a selected local object/embed resource without inline document descriptors.

prepare_mime(value)

@spec prepare_mime(term()) ::
  {:ok, String.t()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Normalizes the supported selected-file MIME vocabulary before reads.

prepare_selection(selected, host)

@spec prepare_selection(term(), term()) ::
  {:ok, :document | :image | :blank, String.t() | nil, String.t() | nil}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Validates a selected dispatch plan and its host before any file work.

select(attributes, context, host \\ :object)

@spec select(
  map(),
  NativeElixirPdfUtilities.HtmlToPdf.ResourceContext.t(),
  :object | :embed
) ::
  {:ok, selected()}
  | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Selects static fallback, blank initialization, an empty embed or a supported local resource before lookup.

validate_content(bytes, descriptor, mime \\ "text/html")

@spec validate_content(binary(), {:file, String.t()}, String.t()) ::
  :ok | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}

Checks selected resource content against file MIME evidence before decoding.