new ValidationRule(ruleName)

Creates a new validation rule object. The rule instances should be frozen.

Parameter

Name Type Optional Description

ruleName

string

 

The name of the rule. It is typically the name of the constructor, without the Rule suffix.

Extends
bo.rules.RuleBase
Throws

Argument error: The rule name must be a non-empty string.

Properties

read-only
primaryProperty  bo.shared.PropertyInfo

The definition of the property the rule relates to.

read-only
ruleName  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

bo.shared.PropertyInfo

 

An affected property influenced by the rule.

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

bo.shared.PropertyInfo

 

An input property that value is used by the rule of.

Throws

Argument error: The input property must be a PropertyInfo object.

protected
getInputValues(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

internal~getValue

 

A function that returns the value of a property.

Throws

Argument error: The getValue argument must be a function..

Returns

object 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

bo.shared.PropertyInfo

 

The property definition the rule relates to.

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 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

string

Yes

Human-readable description of the rule failure.

severity

bo.rules.RuleSeverity

 

The severity of the failed rule.

Returns

bo.rules.ValidationResult The result of the validation rule.