2021-05-22 16:41:55 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2021-05-22 16:41:55 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-06-07 21:01:26 +00:00
|
|
|
defmodule Pleroma.Web.Utils.Params do
|
2021-05-22 16:41:55 +00:00
|
|
|
# As in Mastodon API, per https://api.rubyonrails.org/classes/ActiveModel/Type/Boolean.html
|
|
|
|
@falsy_param_values [false, 0, "0", "f", "F", "false", "False", "FALSE", "off", "OFF"]
|
|
|
|
|
|
|
|
defp explicitly_falsy_param?(value), do: value in @falsy_param_values
|
|
|
|
|
|
|
|
# Note: `nil` and `""` are considered falsy values in Pleroma
|
|
|
|
defp falsy_param?(value),
|
|
|
|
do: explicitly_falsy_param?(value) or value in [nil, ""]
|
|
|
|
|
|
|
|
def truthy_param?(value), do: not falsy_param?(value)
|
|
|
|
end
|