Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/constants/ManiphestTaskStatus.php
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | |||||
/* -( Configuration Validation )------------------------------------------- */ | /* -( Configuration Validation )------------------------------------------- */ | ||||
/** | /** | ||||
* @task validate | * @task validate | ||||
*/ | */ | ||||
public static function isValidStatusConstant($constant) { | public static function isValidStatusConstant($constant) { | ||||
if (strlen($constant) > 12) { | if (!strlen($constant) || strlen($constant) > 64) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!preg_match('/^[a-z0-9]+\z/', $constant)) { | |||||
// Alphanumeric, but not exclusively numeric | |||||
if (!preg_match('/^(?![0-9]*$)[a-zA-Z0-9]+$/', $constant)) { | |||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* @task validate | * @task validate | ||||
*/ | */ | ||||
public static function validateConfiguration(array $config) { | public static function validateConfiguration(array $config) { | ||||
foreach ($config as $key => $value) { | foreach ($config as $key => $value) { | ||||
if (!self::isValidStatusConstant($key)) { | if (!self::isValidStatusConstant($key)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Key "%s" is not a valid status constant. Status constants must '. | 'Key "%s" is not a valid status constant. Status constants '. | ||||
'be 1-12 characters long and contain only lowercase letters (a-z) '. | 'must be 1-64 alphanumeric characters and cannot be exclusively '. | ||||
'and digits (0-9). For example, "%s" or "%s" are reasonable '. | 'digits. For example, "%s" or "%s" are reasonable choices.', | ||||
'choices.', | |||||
$key, | $key, | ||||
'open', | 'open', | ||||
'closed')); | 'closed')); | ||||
} | } | ||||
if (!is_array($value)) { | if (!is_array($value)) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Value for key "%s" should be a dictionary.', | 'Value for key "%s" should be a dictionary.', | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |