Class: MaxLengthRule

bo.commonRules. MaxLengthRule

The rule ensures that the length of the property value does not exceed a given length.

new MaxLengthRule(primaryProperty, maxLength, message, priority, stopsProcessing)

Creates a new max-length rule object.

Parameters:
Name Type Argument Default Description
primaryProperty bo.shared.PropertyInfo

The property definition the rule relates to.

maxLength number

The maximum length of the property value.

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:

Extends

Members

<readonly> maxLength :number

The maximum length of the property value.

Type:
  • number

<readonly> message :string

Human-readable description of the rule failure.

Type:
  • string
Inherited From:

<readonly> primaryProperty :bo.shared.PropertyInfo

The definition of the property the rule relates to.

Type:
Inherited From:

<readonly> priority :number

The priority of the rule. Higher number means higher priority.

Type:
  • number
Inherited From:
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
Inherited From:

<readonly> stopsProcessing :boolean

Indicates whether processing of the rules for a property stops when the rule fails.

Type:
  • boolean
Inherited From:
Default Value:
  • false

Methods

addAffectedProperty(property)

Adds an additional property that is influenced by the rule.

Parameters:
Name Type Description
property bo.shared.PropertyInfo

An affected property influenced by the rule.

Inherited From:
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.

Parameters:
Name Type Description
property bo.shared.PropertyInfo

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

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

<virtual> execute(inputs) → {bo.rules.ValidationResult|undefined}

Checks if the length of the property value does not exceed the defined length.

Parameters:
Name Type Description
inputs Array.<*>

An array of the values of the required properties.

Returns:

Information about the failure.

Type
bo.rules.ValidationResult | undefined

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

Parameters:
Name Type Description
getValue internal~getValue

A function that returns the value of a property.

Inherited From:
Throws:
Argument error: The getValue argument must be a function..
Returns:

An object that properties hold the values of the input properties of.

Type
object

initialize(primaryProperty, message, priority, stopsProcessing)

Sets the properties of the rule.

Parameters:
Name Type Argument Default Description
primaryProperty bo.shared.PropertyInfo

The property definition the rule relates to.

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.

Inherited From:
Throws:

result(message, severity) → {bo.rules.ValidationResult}

Returns the result of the rule executed.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the rule failure.

severity bo.rules.RuleSeverity

The severity of the failed rule.

Inherited From:
Returns:

The result of the validation rule.

Type
bo.rules.ValidationResult
If you find bugs or have feature requests, please let us know.

JavaScript business objects ♦ Copyright © 2014-2016 Logikum, Ltd.
Documentation generated by JSDoc 3.2.2 on 2015. December 31. using the DocStrap template.