Vnu v1.0.0 Vnu.MessageFilter behaviour View Source

A behavior for excluding certain messages from the validation result.

Modules implementing this behavior can be passed as a :filter option to:

Example

defmodule MyApp.VnuMessageFilter do
  @behaviour Vnu.MessageFilter

  @impl Vnu.MessageFilter
  def exclude_message?(%Vnu.Message{message: message}) do
    # those errors are caused by the CSRF meta tag (`csrf_meta_tag()`)
    # present in the layout of a newly-generated Phoenix app
    patterns_to_ignore = [
      ~r/A document must not include more than one “meta” element with a “charset” attribute./,
      ~r/Attribute “(.)*” not allowed on element “meta” at this point./
    ]

    Enum.any?(patterns_to_ignore, &Regex.match?(&1, message))
  end
end

Link to this section Summary

Link to this section Callbacks

Link to this callback

exclude_message?(arg1)

View Source
exclude_message?(Vnu.Message.t()) :: true | false