-
Notifications
You must be signed in to change notification settings - Fork 12
Built In Functions
Tushar Naik edited this page Jan 30, 2024
·
5 revisions
Hope provides a bunch of functions by default for use in Hope expressions.
-
arr.contains_all([lhsArray], [rhsArray])
-true
BooleanValue if lhsArray contains all elements of rhsArray. -
arr.contains_any([lhsArray], [rhsArray])
-true
BooleanValue if lhsArray contains any elements of rhsArray. -
arr.in(lhs, [rhsArray])
-true
BooleanValue if lhs (core type/object) is present in rhsArray. -
arr.not_in(lhs, [rhsArray])
-true
BooleanValue if lhs (core type/object) is not present in rhsArray. -
arr.is_empty(array)
-true
BooleanValue is array is empty -
arr.len(array)
- NumericValue length of the array
-
math.add(num...)
- Sum NumericValue of all provdided numbers -
math.sub(lhs, rhs)
- Result NumericValue after subtracting rhs from lhs -
math.prod(num...)
- Product NumericValue of all provdided numbers -
math.div(num, den)
- Quotient NumericValue of num divided by den -
math.mod(num, den)
- Remainder NumericValue of num divided by den -
math.abs(num)
- Absolute NumericValue of number -
math.ceil(num)
- Ceiling NumericValue of number -
math.floor(num)
- Floor NumericValue of number -
math.neg(num)
- Negative NumericValue of number
-
str.len(str)
- NumericValue length of provided string -
str.lower(str)
- Lower case StringValue of provided string -
str.upper(str)
- Upper case StringValue of provided string -
str.substr(str, beginInclusive[, endExclusive])
- Substring StringValue of provided string that starts at beginInclusive and ends before endExclusive or the end of the string if endExclusive is not provided. -
str.match(regex, str)
-true
BooleanValue is regex matches str
-
path.exists(path)
-true
BooleanValue if field for the given path exists in provided json
-
pointer.exists(pointer)
-true
BooleanValue if field for the given pointer exists in provided json
-
sys.epoch()
- Epoch value milliseconds as NumericValue
-
date.now()
- Current time in epoch milliseconds as NumericValue -
date.second_of_minute()
- The current second as NumericValue of the minute (value between 0-59) -
date.minute_of_hour()
- The current minute as NumericValue of the hour (value between 0-59) -
date.hour_of_day()
- The current hour as NumericValue of the day (value between 0-24) -
date.day_of_week()
- The current day as NumericValue of the week (value between 1-7 where 1=MONDAY; 2=TUESDAY; ... 6=SATURDAY; 7=SUNDAY) -
date.day_of_month()
- The current day as NumericValue of the month (value between 1-31) -
date.day_of_year()
- The current day as NumericValue of the year (value between 1-366) -
date.week_of_month()
- The current week as NumericValue of the month (value between 1-5) -
date.week_of_year()
- The current week as NumericValue of the year (value between 1-53) -
date.month_of_year()
- The current month as NumericValue of the year (value between 1-12) -
date.year()
- The current year as NumericValue (like 2024)