Template talk:Constraint:Format

From Wikidata
Jump to navigation Jump to search

Format question[edit]

Is there any reason to write the format of P:P345 as (tt|nm|ch|co)\d\d\d\d\d\d\d, not simple (tt|nm|ch|co)\d\{7}?--Stevenliuyi (talk) 07:42, 8 May 2013 (UTC)[reply]

Some documentation should be useful. It should also be noted that regular expression paterns should be "quoted" properly ie. '/<pattern>/'. A template may also be useful. See examples below.
  • '/[0-9]/' -> '/\d/'
  • '/[0-7]/' -> '/\o/'
  • '/[0-9a-fA-F]/' -> '/\x/'
  • {{Regexp|pattern=date}} -> '/[012]\d{3}(-(0[1-9]|1[012])(-(0[1-9]|[12]\d|3[01]))?)?/'
  • {{Regexp|pattern=fulldate}} -> '/[012]\d{3}-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])/'
  • {{Regexp|pattern=timestamp}} -> '/[012]\d{3}(0[1-9]|[12]\d|3[01]){2}([01]\d|2[0-3]([0-5]\d){0,2})?/'
  • {{Regexp|pattern=uuid}} -> '/\x{8}-\x{4}-\x{4}-\x{4}-\x{12}/'
Please note what has and has not been implemented. Allen4names (talk) 04:24, 9 May 2013 (UTC)[reply]
I don't think there is a <pattern> tag in MediaWiki and dates aren't currently available as datatype for WikiData. --  Docu  at 07:14, 9 May 2013 (UTC)[reply]
I was writing in the context of regular expressions not the MediaWiki software or the Wikibase extension. Allen4names (talk) 21:22, 12 May 2013 (UTC)[reply]

I, too, would like to know what regex format is used here and by whatever enforces the constraint in case of mandatory=true. PCRE? --Nemo 10:58, 6 March 2015 (UTC)[reply]

empty value[edit]

I think there are a lot of cases where a value must be either empty or matched by this format. Instead of adding this manually to every entry (like I did here), it might be better to add a parameter to this template (something like {{Constraint:Format|[a-z][a-z]|empty}}. What do you think? --Maix (talk) 15:41, 30 October 2013 (UTC)[reply]

Obsolete/use Property:P1793?[edit]

At the moment we are duplicating some information in the constraints templates that is already part of either property statements or the documentation template. This means more work, duplication of information, and it's fairly easy to forget to add either the template or the statement when adding or changing it. In this case, the regular expression is already specified as a format as a regular expression (P1793) statement. @Ivan A. Krestinin: Is it possible for KrBot to automatically check the format of properties, when it has such a statement? Then we could start to retire this template. --Srittau (talk) 10:44, 9 April 2016 (UTC)[reply]

Some time ago we made attempt to move constraints from templates to properties. This attempt was blocked by Wikidata editor limitations. See Wikidata:Contact_the_development_team/Archive/2015/12#Long_qualifiers_list, Property talk:P2302. — Ivan A. Krestinin (talk) 07:40, 10 April 2016 (UTC)[reply]