Enforcer provides the following cateogries of Oasis functions accessible from ALFA. These functions can be used as part of an expression inside a policy.
- String Functions
- Attribute Bag Functions
- Time Functions
- Logical Functions
- Arithmetic Functions
- Conversion Functions
To make use of these functions from inside an ALFA file, use the import statement:
import Oasis.Functions
import Enforcer.Functions
Arithmetic Functions
The following arithmetic functions exist:
Integer Modulo
Namespace : Oasis.Functions
function Mod = "urn:oasis:names:tc:xacml:1.0:function:integer-mod" : input:integer mod:integer -> integer
Takes two integers, performs integer division and returns the remainder.
Example
The following function would return 1.
Mod(7, 3)
Integer Absolute
Namespace : Oasis.Functions
function IntegerAbs = "urn:oasis:names:tc:xacml:1.0:function:integer-abs" : input:integer -> integer
Takes an integer value and returns the absolute value as an integer.
Example
The following functions would return 7.
IntegerAbs(-7)
IntegerAbs(7)
Double Absolute
Namespace : Oasis.Functions
function DoubleAbs = "urn:oasis:names:tc:xacml:1.0:function:double-abs" : input:double -> double
Takes a double value and returns the absolute value as a double.
Example
The following functions would return 7.2.
DoubleAbs(-7.2)
DoubleAbs(7.2)
Money Absolute
Namespace : Oasis.Functions
function MoneyAbs = "urn:rsk:function:money-abs" : input:money -> money
Takes a money value and returns the absolute value as a money.
Example
The following functions would return 7.2m.
MoneyAbs(-7.2:m)
MoneyAbs(7.2:money)
Round
Namespace : Oasis.Functions
function Round = "urn:oasis:names:tc:xacml:1.0:function:round" : input:double -> double
| input:double precision:integer -> double
| input:money -> money
| input:money precision:integer -> money
This signature has two overloads. The first takes a double or money and rounds to the nearest whole number. The second overload accepts an integer to specify the rounding precision.
Example
The following function would return 7.46.
Round(7.456, 2)
Floor
Namespace : Oasis.Functions
function Floor = "urn:oasis:names:tc:xacml:1.0:function:floor" : input:double -> double
| input:money -> money
Takes a double or money and rounds downwards, returning the floor of the value.
Example
The following function would return 7.
Floor(7.456:m)