Help:Special property "Allows pattern"

From semantic-mediawiki.org
Jump to: navigation, search
Allows pattern
Pattern to match a permissible value
Further Information
Provided by: Semantic MediaWiki
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". It was introduced starting with Semantic MediaWiki 2.4.0.1 It is enabled by default. See the help page on the configuration setting $smwgDVFeatures for details on configuring Semantic MediaWiki for special data value features including "Allows pattern" with the SMW_DV_PVAP constant.

The connection between the property and the pattern specification

Features and limitations

NoteNote: 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, the "Has improper value for" special property can be used.

See also