Differential D18157 Diff 43703 src/applications/config/option/PhabricatorApplicationConfigOptions.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/option/PhabricatorApplicationConfigOptions.php
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | switch ($option->getType()) { | ||||
throw new PhabricatorConfigValidationException( | throw new PhabricatorConfigValidationException( | ||||
pht( | pht( | ||||
"Option '%s' must be a set, but array contains values other ". | "Option '%s' must be a set, but array contains values other ". | ||||
"than 'true'.", | "than 'true'.", | ||||
$option->getKey())); | $option->getKey())); | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case 'list<regex>': | |||||
$valid = true; | |||||
if (!is_array($value)) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of regular expressions, but value ". | |||||
"is not an array.", | |||||
$option->getKey())); | |||||
} | |||||
if ($value && array_keys($value) != range(0, count($value) - 1)) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of regular expressions, but the ". | |||||
"value is a map with unnatural keys.", | |||||
$option->getKey())); | |||||
} | |||||
foreach ($value as $v) { | |||||
$ok = @preg_match($v, ''); | |||||
if ($ok === false) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of regular expressions, but the ". | |||||
"value '%s' is not a valid regular expression.", | |||||
$option->getKey(), | |||||
$v)); | |||||
} | |||||
} | |||||
break; | |||||
case 'list<string>': | |||||
$valid = true; | |||||
if (!is_array($value)) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of strings, but value is not ". | |||||
"an array.", | |||||
$option->getKey())); | |||||
} | |||||
if ($value && array_keys($value) != range(0, count($value) - 1)) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of strings, but the value is a ". | |||||
"map with unnatural keys.", | |||||
$option->getKey())); | |||||
} | |||||
foreach ($value as $v) { | |||||
if (!is_string($v)) { | |||||
throw new PhabricatorConfigValidationException( | |||||
pht( | |||||
"Option '%s' must be a list of strings, but it contains one ". | |||||
"or more non-strings.", | |||||
$option->getKey())); | |||||
} | |||||
} | |||||
break; | |||||
case 'wild': | case 'wild': | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
$this->didValidateOption($option, $value); | $this->didValidateOption($option, $value); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |