Help:Special property Allows pattern

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
Is optional: yes
In this wiki: Property:Allows pattern

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


Features and limitations

  • The "Allows pattern" special property can only be assigned via a reference.
  • The "Allows pattern" special property can only validly be assigned once to a property. If more than one assignment is made the last one assigned takes precedence.2
  • The references together with their regular expressions available for the "Allows pattern" special property are provided on page "Smw allows pattern" as a list.
  • Only users with user right smw-patternedit can edit page "Smw allows pattern".
  • The regex modifier /e is not permitted and removed from any expression.

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


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

See also

This documentation page applies to all SMW versions from 2.4.0 to the most current version.

Help:Special property Allows pattern en 2.4.0