class staticbo.rules. RuleBase
Source: rules/
Serves as the base class for rules.
Properties
new RuleBase(ruleName)
Creates a new rule object. The rule instances should be frozen.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
ruleName |
string |
|
The name of the rule. |
- Throws
-
Argument error: The rule name must be a non-empty string.
Properties
read-onlymessage
string
Human-readable description of the rule failure.
read-onlypriority
number
The priority of the rule. Higher number means higher priority.
- Default value
read-onlyruleName
string
The name of the rule type. The default value usually the name of the constructor, without the Rule suffix.
read-onlystopsProcessing
boolean
Indicates whether processing of the rules for a property stops when the rule fails.
- Default value
Methods
abstractexecute(inputs)
Abstract method to check if the rule is valid for the property.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
inputs |
Array of any type |
|
An array of the values of the required properties. |
- Throws
-
Not implemented error: The Rule.execute method is not implemented.
initialize(message[, priority][, stopsProcessing])
Sets the properties of the rule.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
|
Human-readable description of the rule failure. |
priority |
number |
Yes |
The priority of the rule. |
stopsProcessing |
boolean |
Yes |
Indicates the rule behavior in case of failure. |
- Throws
-
Argument error: The message must be a non-empty string.
-
Argument error: The last 3 arguments can be: a string as the message, an integer as the priority and a Boolean as the stopsProcessing argument.
abstractresult([message][, severity]) → object
Abstract method that returns the result of the rule checking.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the rule failure. |
severity |
Yes |
The severity of the rule failure. |
- Throws
-
Not implemented error: The Rule.result method is not implemented.
- Returns
-
object
An object that describes the result of the rule checking.