1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Utils.Params do
6 # As in Mastodon API, per https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
7 @falsy_param_values [false, 0, "0", "f", "F", "false", "False", "FALSE", "off", "OFF"]
9 defp explicitly_falsy_param?(value), do: value in @falsy_param_values
11 # Note: `nil` and `""` are considered falsy values in Pleroma
12 defp falsy_param?(value),
13 do: explicitly_falsy_param?(value) or value in [nil, ""]
15 def truthy_param?(value), do: not falsy_param?(value)