return $prefix . $this->getText();
}
+ public function isOptional() {
+ return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED);
+ }
+
/**
* Validate a parameter value against this
* Convert type as necessary
* @return bool success
*/
public function validateValue(&$value) {
- $optional = $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED);
-
switch ($this->getType()) {
case self::VALUE_BOOLEAN:
if (!is_bool($value)) {
}
break;
default:
- if (!$value && !$optional) {
+ if (!$value && !$this->isOptional()) {
return false;
}
break;
public function validateStorageDefinition(StorageConfig $storage) {
foreach ($this->getParameters() as $name => $parameter) {
$value = $storage->getBackendOption($name);
- if (!$parameter->validateValue($value)) {
- return false;
+ if (!is_null($value) || !$parameter->isOptional()) {
+ if (!$parameter->validateValue($value)) {
+ return false;
+ }
+ $storage->setBackendOption($name, $value);
}
- $storage->setBackendOption($name, $value);
}
return true;
}