Special property "Allows pattern"

From semantic-mediawiki.org
Allows pattern
Pattern to match a permissible value
Further Information
Provided by: extension "Semantic MediaWiki "Allows to store and query data annotated to pages
Added: 2.4.0
Removed: still in use
Alias: has no alias
Optional: yes
Visible: yes
Annotable: yes
Declarative: yes
Key:
_PVAP
Setting:
SMW_DV_PVAP
Focus: property restriction
In this wiki: Property:Allows pattern
Table of Contents

The Allows pattern property is a special property in Semantic MediaWiki with a built-in meaning: it provides the possibility to specify a regular expression pattern to match permissible values. It is similar in it functionality to special property "Allows value"Lists one permissible value for a property. It was introduced starting with Semantic MediaWiki 2.4.0Released on 9 July 2016 and compatible with MW 1.19.0 - 1.27.x..1 It is enabled by default. See the help page on configuration parameter $smwgDVFeaturesSets the available features regarding property data values for details on configuring Semantic MediaWiki for special data value features including "Allows pattern" with the SMW_DV_PVAP option.

The connection between the property and the pattern specification

Features and limitations[edit]

Regular expressions should be well crafted and validated before making them available for pattern matching to avoid potential vulnerabilities.34

Example[edit]

System message "Smw allows pattern" can contain something like:

  • ISBN-10|ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$ - Allows matching a ISBN-105.
    "ISBN-10" is the reference to be added to a property page like e.g. [[Allows pattern::ISBN-10]] "ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$" after the pipe is the assigned regular expression.
  • Whitelist|^(Foo|Foo bar|Bar)$ - Allows whitelisting certain terms.
    "Whitelist" is the reference to be added to a property page like e.g. [[Allows pattern::Whitelist]]. "^(Foo|Foo bar|Bar)$" after the pipe is the assigned regular expression.

See <sandbox.semantic-mediawiki.org> for further examples.

Error Handling[edit]

When [[Foo::Bar]] is used to set a property to a value that is not allowed, the property will not be set, and a warning sign will be shown. When using {{#set: Foo=Bar }} to set the property, the error will be silently ignored. To find all pages that use a value that is not allowed, special property "Has improper value for"Alerts in case the assigned value to a property is invalid can be used.

Note[edit]

The Regular Expression Library (RexExLib.com) is a great resource for finding patterns.

See also[edit]