Javascript MatchingItem

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(String)
(Description)
Line 27: Line 27:
 
'''value''' Value to compare with (string)<br/>
 
'''value''' Value to compare with (string)<br/>
 
'''ignoreCase''' Boolean. Case insensitive comparison. Default: false<br/>
 
'''ignoreCase''' Boolean. Case insensitive comparison. Default: false<br/>
'''negated''' Boolean. Negated match. True: item will match if comparison fails (not the same). Default: false<br/>
+
'''negated''' Boolean. Negated match. Default: false<br/>
  
 
=== RegExp ===
 
=== RegExp ===
Line 34: Line 34:
 
'''name''' Item name<br/>
 
'''name''' Item name<br/>
 
'''value''' Regular expression to match<br/>
 
'''value''' Regular expression to match<br/>
'''negated''' Boolean. Negated match. True: item will match if regular expression don't match. Default: false<br/>
+
'''negated''' Boolean. Negated match. Default: false<br/>
  
 
=== Random ===
 
=== Random ===
Line 42: Line 42:
 
'''value''' <br/>
 
'''value''' <br/>
 
'''maxvalue''' <br/>
 
'''maxvalue''' <br/>
'''negated''' Boolean. Negated match. True: item will match if . Default: false<br/>
+
'''negated''' Boolean. Negated match. Default: false<br/>
  
 
=== List ===
 
=== List ===
Line 50: Line 50:
 
'''name''' Item name<br/>
 
'''name''' Item name<br/>
 
'''value''' Array of matching items<br/>
 
'''value''' Array of matching items<br/>
'''any''' Boolean. True: match if any item matches (logical OR). Default: false (logical AND).<br/>
+
'''any''' Boolean. True: match if any item matches (logical OR). Default: false, match if all items match (logical AND).<br/>
'''negated''' Boolean. Negated match. True: item will match if . Default: false.<br/>
+
'''negated''' Boolean. Negated match. Default: false<br/>
  
 
== Constructor ==
 
== Constructor ==

Revision as of 12:01, 4 September 2024

Contents

General

Object implementing complex matching.
May be set as filter in Message handler and post hook install (match one or more message parameter(s)). May be used for matching individual values

Description

This section describes the matching item types and associted properties.
When matching object properties (e.g. Message parameters) item name indicates a specific property.

NOTE:
Item properties listed here does not belong to a MatchingItem object. They are held in internal item structure and used during matching.
They are present in value returned by getDesc() function.
They are handled in MatchingItem build (constructor) or validate().

In the following example the negated property of mi object is ignored by matching:

var mi = new Engine.MatchingItem("some_value","some_name");
mi.negated = true;
var ok = mi.matches("some_value");
// ok will be true

String

String comparison.
Properties:
name Item name
value Value to compare with (string)
ignoreCase Boolean. Case insensitive comparison. Default: false
negated Boolean. Negated match. Default: false

RegExp

Regular expression match.
Properties:
name Item name
value Regular expression to match
negated Boolean. Negated match. Default: false

Random

Random match.
Properties:
name Item name
value
maxvalue
negated Boolean. Negated match. Default: false

List

List matching.
May contain any matching item including other list(s).
Properties:
name Item name
value Array of matching items
any Boolean. True: match if any item matches (logical OR). Default: false, match if all items match (logical AND).
negated Boolean. Negated match. Default: false

Constructor

  • new Engine.MatchingItem(value[,name[,params])

Build a new MatchingItem object.
Parameters:
value: Value to match. May be another MatchingItem object (all other parameters will be ignored).
name: Parameter name.
params: Build parameters.

If value is a MatchingItem builds a copy of it.

Otherwise build a MatchingItem from received parameters.
See validate() method for processing.
Constructor will fail if validate() would not return an object.
If you are not sure of parameters call validate and then pass the result to constructor:

var obj = Engine.MatchingItem.validate(some_value,some_name,params);
if (obj && "string" != typeof obj)
    obj = new Engine.MatchingItem(obj);
else if (undefined === obj) {
    // Empty ...
}
else {
    // Invalid. obj is an error string
}

Static methods

  • validate(value[,name[,params]])

Parameters:
value: Value to match.
name: Parameter name.
params: Build parameters.
Return:
Success: Object with matching properties. See the description section.
Success with empty optimized matching: undefined
Error: string describing the error


Methods

  • matches(value)


  • getDesc([params])


  • dump([params[,indent,origIndent]])
Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers