class staticbo.system. Utility
Source: system/
Provides static methods for configuration and internationalization.
new Utility()
Creates a new utility object.
Methods
staticgetDirectory(relativePath, name, errorType) → string
Gets the full path of a directory.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
relativePath |
string |
|
The relative path of the directory. |
name |
string |
|
The name of the configuration item. |
errorType |
error |
|
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
-
string
The full path of a directory.
staticgetFunction(relativePath, name, errorType) → function()
Gets a function read from a file.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
relativePath |
string |
|
The relative path of the file to read. |
name |
string |
|
The name of the configuration item. |
errorType |
error |
|
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
-
function()
The required function.
staticisEnumMember(value, enumType, name, errorType) → number
Checks if value is member of a given enumeration.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
value |
(number or string) |
|
The value to check. |
enumType |
constructor |
|
The type of the enumeration. |
name |
string |
|
The name of the configuration item. |
errorType |
error |
|
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
-
number
The checked value.
staticisMandatoryString([value], name, errorType) → string
Checks if value is a non-empty string.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
value |
string |
Yes |
The value to check. |
name |
string |
|
The name of the parameter. |
errorType |
error |
|
The type of the error to throw in case of failure. |
- Throws
-
I18n error: The argument must be a non-empty string.
- Returns
-
string
The checked value.
staticisOptionalString([value], name, errorType) → (string or null)
Checks if value is a string or null.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
value |
(string or null) |
Yes |
The value to check. |
name |
string |
|
The name of the parameter. |
errorType |
error |
|
The type of the error to throw in case of failure. |
- Throws
-
I18n error: The value must be a string value or null.
- Returns
-
(string or null)
The checked value.