new Utility()
Creates a new utility object.
Methods
-
<static> getDirectory(relativePath, name, errorType) → {string}
-
Gets the full path of a directory.
Parameters:
Name Type Description relativePathstring The relative path of the directory.
namestring The name of the configuration item.
errorTypeerror The type of the error to throw in case of failure.
Throws:
-
Configuration I18n error: The property value of business objects' configuration must be a string.
-
Configuration I18n error: The property value of business objects' configuration is not a valid directory path.
Returns:
The full path of a directory.
- Type
- string
-
-
<static> getFunction(relativePath, name, errorType) → {function}
-
Gets a function read from a file.
Parameters:
Name Type Description relativePathstring The relative path of the file to read.
namestring The name of the configuration item.
errorTypeerror The type of the error to throw in case of failure.
Throws:
-
Configuration I18n error: The property value of business objects' configuration must be a string.
-
Configuration I18n error: The property value of business objects' configuration is not a valid file path.
-
Configuration I18n error: The file defined by the property of business objects' configuration must return a function.
Returns:
The required function.
- Type
- function
-
-
<static> isEnumMember(value, enumType, name, errorType) → {number}
-
Checks if value is member of a given enumeration.
Parameters:
Name Type Description valuenumber | string The value to check.
enumTypeconstructor The type of the enumeration.
namestring The name of the configuration item.
errorTypeerror The type of the error to throw in case of failure.
Throws:
-
Configuration error: Type is not an enumeration type.
-
Configuration error: The argument must be an enumeration type item.
Returns:
The checked value.
- Type
- number
-
-
<static> isMandatoryString(value, name, errorType) → {string}
-
Checks if value is a non-empty string.
Parameters:
Name Type Argument Description valuestring <optional>
The value to check.
namestring The name of the parameter.
errorTypeerror The type of the error to throw in case of failure.
Throws:
I18n error: The argument must be a non-empty string.Returns:
The checked value.
- Type
- string
-
<static> isOptionalString(value, name, errorType) → {string|null}
-
Checks if value is a string or null.
Parameters:
Name Type Argument Default Description valuestring | null <optional>
null The value to check.
namestring The name of the parameter.
errorTypeerror The type of the error to throw in case of failure.
Throws:
I18n error: The value must be a string value or null.Returns:
The checked value.
- Type
- string | null