Packages

fnord

0.9.21

AI code archaeology

Current section

Files

Jump to
fnord lib settings approvals regex_matcher.ex
Raw

lib/settings/approvals/regex_matcher.ex

defmodule Settings.Approvals.RegexMatcher do
@moduledoc """
Provides functions to compile and match regular expression patterns for approvals.
"""
@doc """
Tests whether a single pattern string matches the given subject.
Returns false if either argument is not a binary.
"""
@spec matches?(String.t(), String.t()) :: boolean
def matches?(pattern, subject) when is_binary(pattern) and is_binary(subject) do
Regex.match?(Regex.compile!(pattern, "u"), subject)
end
def matches?(_, _), do: false
end