for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace mindplay\kissform\Validators;
use mindplay\kissform\Facets\FieldInterface;
use mindplay\kissform\Facets\ValidatorInterface;
use mindplay\kissform\InputModel;
use mindplay\kissform\InputValidation;
use mindplay\lang;
/**
* Validate required input
*/
class CheckRequired implements ValidatorInterface
{
* @var string|null
private $error;
* @param string $error optional custom error message
$error
string|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
public function __construct($error = null)
$this->error = $error;
}
public function validate(FieldInterface $field, InputModel $model, InputValidation $validation)
if ($model->getInput($field) === null) {
$model->setError(
$field,
$this->error ?: lang::text("mindplay/kissform", "required", ["field" => $validation->getLabel($field)])
);
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.