diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-07-13 22:47:47 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-07-13 22:47:47 -0500 |
commit | deb3f911366925bcc342a4a0deb44a2e7da7f1ba (patch) | |
tree | c8e587198f64c4c5f991a05561943c6bd0af465b /lib/pleroma/web/utils/params.ex | |
parent | 5e88796784e0ac2dbf57d9cf954fdc8ae8aeae43 (diff) | |
parent | 173e977e283789a814278c63bc81f40a13942e21 (diff) | |
download | pleroma-deb3f911366925bcc342a4a0deb44a2e7da7f1ba.tar.gz |
Merge remote-tracking branch 'pleroma/develop' into admin-api-users-sort
Diffstat (limited to 'lib/pleroma/web/utils/params.ex')
-rw-r--r-- | lib/pleroma/web/utils/params.ex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/pleroma/web/utils/params.ex b/lib/pleroma/web/utils/params.ex new file mode 100644 index 000000000..6e0900341 --- /dev/null +++ b/lib/pleroma/web/utils/params.ex @@ -0,0 +1,16 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.Utils.Params do + # 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 |