@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 64 lines 1.9 kB view raw
1<?php 2 3final class AlmanacNames extends Phobject { 4 5 public static function validateName($name) { 6 if (strlen($name) < 3) { 7 throw new Exception( 8 pht( 9 'Almanac service, device, property, network and namespace names '. 10 'must be at least 3 characters long.')); 11 } 12 13 if (strlen($name) > 100) { 14 throw new Exception( 15 pht( 16 'Almanac service, device, property, network and namespace names '. 17 'may not be more than 100 characters long.')); 18 } 19 20 if (!preg_match('/^[a-z0-9.-]+\z/', $name)) { 21 throw new Exception( 22 pht( 23 'Almanac service, device, property, network and namespace names '. 24 'may only contain lowercase letters, numbers, hyphens, and '. 25 'periods.')); 26 } 27 28 if (preg_match('/(^|\\.)\d+(\z|\\.)/', $name)) { 29 throw new Exception( 30 pht( 31 'Almanac service, device, network, property and namespace names '. 32 'may not have any segments containing only digits.')); 33 } 34 35 if (preg_match('/\.\./', $name)) { 36 throw new Exception( 37 pht( 38 'Almanac service, device, property, network and namespace names '. 39 'may not contain multiple consecutive periods.')); 40 } 41 42 if (preg_match('/\\.-|-\\./', $name)) { 43 throw new Exception( 44 pht( 45 'Almanac service, device, property, network and namespace names '. 46 'may not contain hyphens adjacent to periods.')); 47 } 48 49 if (preg_match('/--/', $name)) { 50 throw new Exception( 51 pht( 52 'Almanac service, device, property, network and namespace names '. 53 'may not contain multiple consecutive hyphens.')); 54 } 55 56 if (!preg_match('/^[a-z0-9].*[a-z0-9]\z/', $name)) { 57 throw new Exception( 58 pht( 59 'Almanac service, device, property, network and namespace names '. 60 'must begin and end with a letter or number.')); 61 } 62 } 63 64}