class staticbo.commonRules. ExpressionRule
Source: common-rules/
The rule ensures that the property value matches a regular expression.
new ExpressionRule(primaryProperty, regex, option, message[, priority][, stopsProcessing])
Creates a new expression rule object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
primaryProperty |
|
The property definition the rule relates to. |
|
regex |
regexp |
|
The regular expression that specifies the rule. |
option |
|
The action to execute when the value is null. |
|
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. |
- Extends
- bo.rules.ValidationRule
- Throws
-
Argument error: The primary property must be a PropertyInfo object.
-
Argument error: The regular expression must be a RegExp object.
-
Argument error: The option must be a NullResultOption item.
-
Argument error: The message must be a non-empty string.
Properties
read-onlyoption
number
The action to execute when the value of the property is null.
read-onlyregex
number
The regular expression that the property value has to conform.
read-onlyruleName
string
The name of the rule type. The default value usually the name of the constructor, without the Rule suffix.
- Inherited from
- bo.rules.RuleBase#ruleName
Methods
addAffectedProperty(property)
Adds an additional property that is influenced by the rule.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
property |
|
|
An affected property influenced by the rule. |
- Inherited from
- bo.rules.ValidationRule#addAffectedProperty
- Throws
-
Argument error: The affected property must be a PropertyInfo object.
addInputProperty(property)
Adds an additional property to the rule that will use its value.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
property |
|
|
An input property that value is used by the rule of. |
- Inherited from
- bo.rules.ValidationRule#addInputProperty
- Throws
-
Argument error: The input property must be a PropertyInfo object.
abstractexecute(inputs) → (bo.rules.ValidationResult or undefined)
Checks if the value of the property matches the regular expression.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
inputs |
Array of any type |
|
An array of the values of the required properties. |
- Returns
-
(bo.rules.ValidationResult or undefined)
Information about the failure.
protectedgetInputValues(getValue) → object
Returns the values of the properties that are used by the rule. This method is called by the rule manager internally to provide the values of the input properties for the execute() method.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
getValue |
|
|
A function that returns the value of a property. |
- Inherited from
- bo.rules.ValidationRule#getInputValues
- Throws
-
Argument error: The getValue argument must be a function..
- Returns
-
An object that properties hold the values of the input properties of.
initialize(primaryProperty, message[, priority][, stopsProcessing])
Sets the properties of the rule.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
primaryProperty |
|
|
The property definition the rule relates to. |
message |
|
|
Human-readable description of the rule failure. |
priority |
|
Yes |
The priority of the rule. |
stopsProcessing |
|
Yes |
Indicates the rule behavior in case of failure. |
- Inherited from
- bo.rules.ValidationRule#initialize
- Throws
-
Argument error: The primary property must be a PropertyInfo object.
-
Argument error: The message must be a non-empty string.
result([message], severity) → bo.rules.ValidationResult
Returns the result of the rule executed.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
|
Yes |
Human-readable description of the rule failure. |
severity |
|
|
The severity of the failed rule. |
- Inherited from
- bo.rules.ValidationRule#result
- Returns
-
The result of the validation rule.