diff --git a/src/Prompt.php b/src/Prompt.php index 128fa1ec..fcc80baf 100644 --- a/src/Prompt.php +++ b/src/Prompt.php @@ -307,9 +307,9 @@ private function validate(mixed $value): void { $this->validated = true; - if (($this->required ?? false) && $this->isInvalidWhenRequired($value)) { + if ($this->required !== false && $this->isInvalidWhenRequired($value)) { $this->state = 'error'; - $this->error = is_string($this->required) ? $this->required : 'Required.'; + $this->error = is_string($this->required) && strlen($this->required) > 0 ? $this->required : 'Required.'; return; }