bool`, to validate the given string * @param callable(string): ValidationFail[] $errorsFactory a factory function with signature `(string) => array` to emit failures when the predicate fails */ public function __construct(callable $predicate, callable $errorsFactory) { $this->predicate = $predicate; $this->errorFactory = $errorsFactory; } public function validate(string $name, $val): array { if (!call_user_func_array($this->predicate, [$val])) { return call_user_func_array($this->errorFactory, [$name]); } return []; } }