|
|
@@ -35,22 +35,24 @@ class DiskSizeValidator extends BaseValidator
|
|
|
$additionalSize = (int) $additionalData->get('formData')[$this->additionalField];
|
|
|
}
|
|
|
$diskResource = $resurceManager->disk();
|
|
|
+ # find available space in VDC
|
|
|
$diskResource->setTotal($diskResource->getTotal()-$additionalSize);
|
|
|
if ($this->isWhmcsConfigOption(ConfigurableOption::STORAGE)) {
|
|
|
$this->maxValue = $this->getWhmcsConfigOption(ConfigurableOption::STORAGE) - $diskResource->getUsed();
|
|
|
} else {
|
|
|
$this->maxValue = $diskResource->free();
|
|
|
}
|
|
|
-
|
|
|
+ # reduce available space to server limits
|
|
|
if ($this->maxValue > $diskResource->getMax()) {
|
|
|
$this->maxValue = $diskResource->getMax();
|
|
|
}
|
|
|
-
|
|
|
$this->minValue = $diskResource->getMin();
|
|
|
+ # reject floating point
|
|
|
if(preg_match("/\./", $data)){
|
|
|
$this->addValidationError('PleaseProvideANumericValueBetween', false, ['minValue' => $this->minValue, 'maxValue' => $this->maxValue]);
|
|
|
return false;
|
|
|
}
|
|
|
+ # accept if no limits
|
|
|
if (is_numeric($data) && $this->minValue === 0 && $this->maxValue === 0)
|
|
|
{
|
|
|
return true;
|