logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

params.ex (668B)


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