-
Notifications
You must be signed in to change notification settings - Fork 0
ConditionsClass
Checks if a condition is true or false.
Parameters
-
condition
(boolean
) - The condition to check -
message
(string?
) - The message to return if the condition is false
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is(true)
-- true, nil
conditions.is(false, "Expected condition to be false")
-- false, "Expected condition to be false"
Checks if two values are deeply equal.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not deeply equal
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_deeply({a = 1}, {a = 1})
-- true, nil
Checks if two values are equal.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not equal
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_eq(1, 1)
-- true, nil
conditions.is_eq(1, 2, "Expected values to be equal")
-- false, "Expected values to be equal"
Checks if a function throws an error.
Parameters
-
func
(function
) - The function to check -
message
(string?
) - The message to return if the function does not throw an error -
check
(function?
) - The function to check the error message against
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_error(function() error("Expected error") end, "Expected error")
-- false, "Expected error"
Checks if a condition is false.
Parameters
-
condition
(boolean
) - The condition to check -
message
(string?
) - The message to return if the condition is true
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_false(false)
-- false, nil
conditions.is_false(true, "Expected condition to be false")
-- true, "Expected condition to be false"
Checks if a value is greater than or equal to another value.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not greater than or equal to
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_ge(2, 1)
-- true, nil
conditions.is_ge(1, 2, "Expected values to be greater than or equal to")
-- false, "Expected values to be greater than or equal to"
Checks if a value is greater than another value.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not greater than
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_gt(2, 1)
-- true, nil
conditions.is_gt(1, 2, "Expected values to be greater than")
-- false, "Expected values to be greater than"
Checks if a value is less than or equal to another value.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not less than or equal to
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_le(1, 2)
-- true, nil
conditions.is_le(2, 1, "Expected values to be less than or equal to")
-- false, "Expected values to be less than or equal to"
Checks if a value is less than another value.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are not less than
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_lt(1, 2)
-- true, nil
conditions.is_lt(2, 1, "Expected values to be less than")
-- false, "Expected values to be less than"
Checks if two values are not equal.
Parameters
-
a
(any
) - The first value to check -
b
(any
) - The second value to check -
message
(string?
) - The message to return if the values are equal
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_ne(1, 2)
-- true, nil
conditions.is_ne(1, 1, "Expected values to not be equal")
-- false, "Expected values to not be equal"
Checks if a value is nil.
Parameters
-
value
(any
) - The value to check -
message
(string?
) - The message to return if the value is nil
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_nil(nil)
-- true, nil
conditions.is_nil(false, "Expected value to be nil")
-- false, "Expected value to be nil"
Checks if a value is not nil.
Parameters
-
value
(any
) - The value to check -
message
(string?
) - The message to return if the value is nil
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_not_nil(false)
-- false, nil
conditions.is_not_nil(nil, "Expected value to not be nil")
-- true, "Expected value to not be nil"
Checks if a condition is true.
Parameters
-
condition
(boolean
) - The condition to check -
message
(string?
) - The message to return if the condition is false
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_true(true)
-- true, nil
conditions.is_true(false, "Expected condition to be true")
-- false, "Expected condition to be true"
Checks if a value is of a specific type.
Parameters
-
value
(any
) - The value to check -
type
(string
) - The type to check against -
message
(string?
) - The message to return if the values are not of the specified type
Returns
boolean
, string?
- The condition and message, or nil if the condition is true
Examples
conditions.is_type(1, "number")
-- true, nil
conditions.is_type(1, "string", "Expected value to be a string")
-- false, "Expected value to be a string"
Documentation generated with Gludoc.