new RuleBase(ruleName)
Creates a new rule object. The rule instances should be frozen.
Parameters:
Name | Type | Description |
---|---|---|
ruleName |
string | The name of the rule. |
Throws:
Members
-
<readonly> message :string
-
Human-readable description of the rule failure.
Type:
- string
-
<readonly> priority :number
-
The priority of the rule. Higher number means higher priority.
Type:
- number
- Default Value:
-
- 10
-
<readonly> ruleName :string
-
The name of the rule type. The default value usually the name of the constructor, without the Rule suffix.
Type:
- string
-
<readonly> stopsProcessing :boolean
-
Indicates whether processing of the rules for a property stops when the rule fails.
Type:
- boolean
- Default Value:
-
- false
Methods
-
<virtual> execute(inputs)
-
Abstract method to check if the rule is valid for the property.
Parameters:
Name Type Description inputs
Array.<*> 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 Argument Default Description message
string Human-readable description of the rule failure.
priority
number <optional>
10 The priority of the rule.
stopsProcessing
boolean <optional>
false 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.
-
-
<virtual> result(message, severity) → {object}
-
Abstract method that returns the result of the rule checking.
Parameters:
Name Type Argument Description message
string <optional>
Human-readable description of the rule failure.
severity
bo.rules.RuleSeverity <optional>
The severity of the rule failure.
Throws:
Not implemented error: The Rule.result method is not implemented.Returns:
An object that describes the result of the rule checking.
- Type
- object