This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
validate.not empty
Daniel Gorman edited this page Sep 25, 2019
·
1 revision
validate.not-empty
returns a given value if the value is not empty, or an error if the value is empty. Collections with no elements, including empty strings, are considered empty.
validate.not-empty(arg1, arg2)
-
arg1
is the datum or a reference to a datum. -
arg2
is the error message to return if arg1 evaluates to null.
Given the following data structure:
{
"driver_ids":
{
"first": 999,
"second": ""
}
}
If we want to perform an operation but aren't sure whether the value will is empty or not, we can confirm that it isn't (or is) with validate.not-empty
:
validate.not-empty(driver_ids.first, "This error message won't be executed")
Will return 999
.
validate.not-empty(driver_ids.second, "Value was empty!")
Will return "Value was empty!"
.