28 lines
824 B
PHP
28 lines
824 B
PHP
<?php
|
|
|
|
namespace com\fwdekker\deathnotifier\validator;
|
|
|
|
use com\fwdekker\deathnotifier\Response;
|
|
|
|
|
|
/**
|
|
* Requires the input to not be blank.
|
|
*/
|
|
class IsNotBlankRule extends Rule
|
|
{
|
|
/**
|
|
* Checks whether the input is not blank.
|
|
*
|
|
* @param array<string, mixed> $inputs the list of inputs in which the value at `key` should be checked
|
|
* @param string $key the key in `inputs` of the input to check
|
|
* @return Response|null `null` if `trim($inputs[$key])` is not an empty string, or an unsatisfied `Response`
|
|
* otherwise
|
|
*/
|
|
public function check(array $inputs, string $key): ?Response
|
|
{
|
|
return !isset($inputs[$key]) || trim($inputs[$key]) === ""
|
|
? Response::unsatisfied($this->override_message ?? "Use at least one character.", $key)
|
|
: null;
|
|
}
|
|
}
|