make 2fa UI less awful
[akkoma] / lib / pleroma / web / utils / params.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
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"]
8
9 defp explicitly_falsy_param?(value), do: value in @falsy_param_values
10
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, ""]
14
15 def truthy_param?(value), do: not falsy_param?(value)
16 end