Special property "Allows pattern"

From semantic-mediawiki.org
Allows pattern
Pattern to match a permissible value
Further Information
Provided by: extension "Semantic MediaWiki "Semantic MediaWiki (SMW) is a free, open-source extension to MediaWiki that lets you store and query data within the wiki's pages. Semantic MediaWiki is also a full-fledged framework, in conjunction with many spinoff extensions, that can turn a wiki into a powerful and flexible knowledge management system. All data created within SMW can easily be published via the Semantic Web, allowing other systems to use this data seamlessly.
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

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

Example

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

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.

See also