src/Util/Validator.php
public function error(string $field, string $message, array $params = [])
    {
        $message = $this->checkAndSetLabel($field, $message, $params);

        $values = [];
        // Printed values need to be in string format
        foreach ($params as $param) {
            if (\is_array($param)) {
                $param = "['" . implode("', '", $param) . "']";
            } elseif ($param instanceof \DateTime) {
                $param = $param->format('Y-m-d');
            } elseif (\is_object($param)) {
                $param = \get_class($param);
            }

            // Use custom label instead of field name if set
            if (\is_string($params[0]) && isset($this->_labels[$param])) {
                $param = $this->_labels[$param];
            }
            $values[] = $param;
        }

        $this->_errors[$field][] = \vsprintf($message, $values);
    }
public function error(string $field, string $message, array $params = [])
    {
        $message = $this->checkAndSetLabel($field, $message, $params);

        $values = [];
        // Printed values need to be in string format
        foreach ($params as $param) {
            if (\is_array($param)) {
                $param = "['" . implode("', '", $param) . "']";
            } elseif ($param instanceof \DateTime) {
                $param = $param->format('Y-m-d');
            } elseif (\is_object($param)) {
                $param = \get_class($param);
            }

            // Use custom label instead of field name if set
            if (\is_string($params[0]) && isset($this->_labels[$param])) {
                $param = $this->_labels[$param];
            }
            $values[] = $param;
        }

        $this->_errors[$field][] = \vsprintf($message, $values);
    }
public function error ( string $ field , string $ message , array $ params = [ ] ) { $ message = $ this -> checkAndSetLabel ( $ field , $ message , $ params ) ; $ values = [ ] ; // Printed values need to be in string format foreach ( $ params as $ param ) { if ( \ is_array ( $ param ) ) { $ param = "['" . implode ( "', '" , $ param ) . "']" ; } elseif ( $ param instanceof \ DateTime ) { $ param = $ param -> format ( 'Y-m-d' ) ; } elseif ( \ is_object ( $ param ) ) { $ param = \ get_class ( $ param ) ; } // Use custom label instead of field name if set if ( \ is_string ( $ params [ 0 ] ) && isset ( $ this -> _labels [ $ param ] ) ) { $ param = $ this -> _labels [ $ param ] ; } $ values [ ] = $ param ; } $ this -> _errors [ $ field ] [ ] = \ vsprintf ( $ message , $ values ) ; }
Add an error to error messages array

@param string $field
@param string $message
@param array  $params
Add an error to error messages array