Help:Property constraints portal/Value type

From Wikidata
Jump to navigation Jump to search

Other languages:
Deutsch • ‎English • ‎français • ‎polski • ‎svenska • ‎русский • ‎српски / srpski • ‎العربية
Pictogram voting arrow.svg

value type constraint (Q21510865) specifies that values of a given property should have a given type. This is also known as the range of a property.

For example, values for mother (P25) should be instance of (P31) human (Q5) or animal (Q729), and values for space launch vehicle (P375) should be subclass of (P279) launch vehicle (Q697175).

Subclass relations according to subclass of (P279) are taken into account: if a constraint demands that an item should be an instance of building (Q41176), it is not a violation if the item is an instance of skyscraper (Q11303), because there is a subclass of (P279) path from skyscraper (Q11303) to building (Q41176). (If an indirect relation should not be permitted, value requires statement constraint (Q21510864) can be used.) Longish paths sometimes time-out and don't work in all tools.

If no constraint scope (P4680) is specified, this constraint is checked everywhere.

Possible actions[edit]

There are several possible ways to address a violation of this constraint:

Parameters[edit]

This constraint has two parameters (both mandatory):

relation (P2309)
Must be instance of (Q21503252), subclass of (Q21514624), or instance or subclass of (Q30208840). Describes whether the item should be an instance of the class(es), or a subclass of it/them, or whether both are allowed. This parameter must only be given once.
class (P2308)
Lists the classes that are allowed for the value. Each class must be an item ID (no value Help or unknown value Help is not permitted). If more than one class is specified, the constraint is satisfied as long as the value has at least one of these types.


Examples[edit]

Example 1[edit]

Values for adjacent station (P197) should be instance of station (Q719456).

property constraint
Normal rank value type constraint Arbcom ru editing.svg edit
class station
relation instance of
▼ 0 reference
+ add reference
+ add value

Example 2[edit]

Values for space launch vehicle (P375) should be subclass of launch vehicle.

property constraint
Normal rank value type constraint Arbcom ru editing.svg edit
class launch vehicle
relation subclass of
▼ 0 reference
+ add reference
+ add value

Template[edit]

When the constraint is set to the property, the following template is automatically displayed in the property talk page. The template is created by Module:Constraints using {{Constraint}}, invoked from {{Property documentation}}. Translations are defined at Module:i18n/constraints.

Value type “station (Q719456): This property should use items as value that contain property “instance of (P31)”. On these, the value for instance of (P31) should be an item that uses subclass of (P279) with value station (Q719456) (or a subclass thereof). (Help)
Exceptions are possible as rare values may exist.
List of this constraint violations: Database reports/Constraint violations/P197#Value type Q719456, SPARQL, SPARQL (new)

Lists[edit]

Lists of properties which are set value type constraint.