Довідка:Портал обмежень властивостей/Формат

This page is a translated version of the page Help:Property constraints portal/Format and the translation is 52% complete.
Outdated translations are marked like this.

format constraint (Q21502404) вказує, що значення властивості повинні відповідати певному шаблону.

Наприклад, значення для GNIS Feature ID (P590) завжди повинно бути числом, що містить до восьми цифр, без початкових нулів: [1-9][0-9]{0,7}.

The pattern is a regular expression, but the flavor varies: KrBot, which creates the database reports, uses PCRE; the WikibaseQualityConstraints extension, which powers the live constraint checks and Special:ConstraintReport, uses PCRE since August 2021 (having previously used java.util.regex); OpenRefine uses java.util.regex; other implementations may use something else to check regular expressions. The flavors are mostly, but not entirely compatible; for maximum compatibility with different constraint engines, it’s recommended to stick to the common subset of the flavors.

Якщо не вказано constraint scope (P4680), це обмеження перевіряється всюди.

Можливі дії

Існує декілька можливих способів вирішення проблеми порушення цього обмеження:

  • Найбільш вірогідним є те, що так чи інакше неправильно формується значення. Часто виправлення є простим: додайте відсутній префікс або вилучіть його, якщо він має бути неявним, додайте пунктуацію (наприклад, додайте дефіс до номера ISBN), виправте велику літеру тощо.
  • Цілком можливо, що значення правильне, але не належить до цієї властивості, і що його потрібно перемістити у твердження для іншої властивості (наприклад, ISBN-13 (P212) в ISBN-10 (P957)).
  • Можливо, що ідентифікатор розширив свій діапазон, і регулярний вираз треба адаптувати (наприклад, ідентифікатор тепер використовує до 15 цифр, а не 10, як тоді, коли він був вперше визначений).
  • Цілком можливо, що елемент є рідкісним, але законним винятком з обмеження, і нічого не треба робити.

Параметри

Це обмеження має один обов'язковий і один необов'язковий параметр:

format as a regular expression (P1793)
Містить формат (шаблон). Має містити рівно одне значення (no value Help або unknown value Help не допускається), яке має бути правильним регулярним виразом.
syntax clarification (P2916)
Містить легкий для читання опис шаблону. Можна вказати декілька разів на різних мовах.

Examples

Example 1

Values for image (P18) should end with certain file extension like .jpg or .png.

property constraint
  format constraint
format as a regular expression (?i).+\.(jpg|jpeg|png|svg|tif|tiff|gif|xcf)
0 references
add reference


add value

Example 2

Using syntax clarification (P2916) parameter for explaining the regular expression in human-readable text. For example, value of IPA transcription (P898) doesn't contain : (colon) or ' (apostrophe). Correct character is ː (length) or ˈ (stress). This regular expression is difficult to understand without explanation.

property constraint
  format constraint
format as a regular expression [^:]+
syntax clarification colon is not a valid IPA character, the correct character for a length mark is ː (English)
0 references
add reference
  format constraint
format as a regular expression [^']+
syntax clarification apostrophe is not a valid IPA character, the correct character for primary stress is ˈ (English)
0 references
add reference


add value

Template

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 Template:Constraint, invoked from Template:Property documentation. Translations are defined at Module:i18n/constraints.

Format “(?i).+\.(jpg|jpeg|jpe|png|svg|tif|tiff|gif|xcf|pdf|djvu|webp)|: value must be formatted using this pattern (PCRE syntax). (Help)
Exceptions are possible as rare values may exist. Exceptions can be specified using exception to constraint (P2303).
List of violations of this constraint: Database reports/Constraint violations/P18#Format, SPARQL

Lists

Lists of properties which are set format constraint.