View Source Appwrite.Consts.ImageGravity (appwrite v0.1.7)
Provides constants and validation functions for image gravity (positioning) values.
This module defines various image gravity options, such as center, top-left, bottom-right, etc.
Helper functions are included to validate these gravity values, ensuring only recognized positioning options are used.
Summary
Functions
Returns true if the given gravity is a valid image gravity value.
Guard clause to check if a given image gravity is a valid image gravity code.
Validates the given gravity and returns {:ok, gravity} if it is valid,
or {:error, "Invalid image gravity"} otherwise.
Returns the given gravity if it is valid. Raises an ArgumentError
if the gravity is invalid.
Functions
Returns true if the given gravity is a valid image gravity value.
Examples
iex> ImageGravity.is_valid_gravity?("top-left")
true
iex> ImageGravity.is_valid_gravity?("middle")
false
Guard clause to check if a given image gravity is a valid image gravity code.
Examples
iex> ImageGravity.valid_gravity("center")
true
iex> ImageGravity.valid_gravity("down_right")
false
Validates the given gravity and returns {:ok, gravity} if it is valid,
or {:error, "Invalid image gravity"} otherwise.
Examples
iex> ImageGravity.validate_gravity("top-right")
{:ok, "top-right"}
iex> ImageGravity.validate_gravity("middle")
{:error, "Invalid image gravity"}
Returns the given gravity if it is valid. Raises an ArgumentError
if the gravity is invalid.
Examples
iex> ImageGravity.validate_gravity!("center")
"center"
iex> ImageGravity.validate_gravity!("middle")
** (ArgumentError) Invalid image gravity: "middle"