for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fiv\Form\Validator;
/**
* Check if value not empty
* Algorithm based on value length
*
*/
class Required extends BaseValidator {
* @var string
protected $error = 'Field is required';
* @param string $error
* @return $this
public function setError($error) {
$this->error = $error;
return $this;
}
* @param string $value
* @return bool
public function isValid($value) {
$this->errors = [];
if (!empty($value)) {
return true;
if (is_string($value) and $value !== '') {
$this->addError($this->error);
return false;