diff --git a/src/Components/AjaxSelect/Traits/InvalidSetValueTrait.php b/src/Components/AjaxSelect/Traits/InvalidSetValueTrait.php index efcb54c..073451a 100644 --- a/src/Components/AjaxSelect/Traits/InvalidSetValueTrait.php +++ b/src/Components/AjaxSelect/Traits/InvalidSetValueTrait.php @@ -26,6 +26,11 @@ public function getInvalidValueMode() { * @return $this */ public function setInvalidValueMode($mode) { + + if (!in_array($mode, [AjaxSelect\DI\AjaxSelectExtension::INVALID_VALUE_MODE_EXCEPTION, AjaxSelect\DI\AjaxSelectExtension::INVALID_VALUE_MODE_EMPTY])) { + throw new \InvalidArgumentException("Invalid parameter mode, use one of AjaxSelect\DI\AjaxSelectExtension::INVALID_VALUE_MODE_*."); + } + $this->invalidValueMode = $mode; return $this; } @@ -52,8 +57,6 @@ protected function handleInvalidValues($values) { ? [ ] : NULL; break; } - - return $this; } public function setValue($value) {