gump.class.php
public function get_errors_array($convert_to_string = null)
    {
        if (empty($this->errors)) {
            return ($convert_to_string) ? null : array();
        }

        $resp = array();

        // Error messages
        $messages = $this->get_messages();

        foreach ($this->errors as $e)
        {
            $field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
            $param = $e['param'];

            // Let's fetch explicitly if the field names exist
            if (array_key_exists($e['field'], self::$fields)) {
                $field = self::$fields[$e['field']];

                // If param is a field (i.e. equalsfield validator)
                if (array_key_exists($param, self::$fields)) {
                    $param = self::$fields[$e['param']];
                }
            }

            // Messages
            if (isset($messages[$e['rule']])) {
                // Show first validation error and don't allow to be overwritten
                if (!isset($resp[$e['field']])) {
                    if (is_array($param)) {
                        $param = implode(', ', $param);
                    }
                    $message = str_replace('{param}', $param, str_replace('{field}', $field, $messages[$e['rule']]));
                    $resp[$e['field']] = $message;
                }
            } else {
                throw new \Exception ('Rule "'.$e['rule'].'" does not have an error message');
            }
        }

        return $resp;
    }
public function get_errors_array($convert_to_string = null)
    {
        if (empty($this->errors)) {
            return ($convert_to_string) ? null : array();
        }

        $resp = array();

        // Error messages
        $messages = $this->get_messages();

        foreach ($this->errors as $e)
        {
            $field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
            $param = $e['param'];

            // Let's fetch explicitly if the field names exist
            if (array_key_exists($e['field'], self::$fields)) {
                $field = self::$fields[$e['field']];

                // If param is a field (i.e. equalsfield validator)
                if (array_key_exists($param, self::$fields)) {
                    $param = self::$fields[$e['param']];
                }
            }

            // Messages
            if (isset($messages[$e['rule']])) {
                // Show first validation error and don't allow to be overwritten
                if (!isset($resp[$e['field']])) {
                    if (is_array($param)) {
                        $param = implode(', ', $param);
                    }
                    $message = str_replace('{param}', $param, str_replace('{field}', $field, $messages[$e['rule']]));
                    $resp[$e['field']] = $message;
                }
            } else {
                throw new \Exception ('Rule "'.$e['rule'].'" does not have an error message');
            }
        }

        return $resp;
    }
public function get_errors_array ( $ convert_to_string = null ) { if ( empty ( $ this -> errors ) ) { return ( $ convert_to_string ) ? null : array ( ) ; } $ resp = array ( ) ; // Error messages $ messages = $ this -> get_messages ( ) ; foreach ( $ this -> errors as $ e ) { $ field = ucwords ( str_replace ( array ( '_' , '-' ) , chr ( 32 ) , $ e [ 'field' ] ) ) ; $ param = $ e [ 'param' ] ; // Let's fetch explicitly if the field names exist if ( array_key_exists ( $ e [ 'field' ] , self :: $ fields ) ) { $ field = self :: $ fields [ $ e [ 'field' ] ] ; // If param is a field (i.e. equalsfield validator) if ( array_key_exists ( $ param , self :: $ fields ) ) { $ param = self :: $ fields [ $ e [ 'param' ] ] ; } } // Messages if ( isset ( $ messages [ $ e [ 'rule' ] ] ) ) { // Show first validation error and don't allow to be overwritten if ( ! isset ( $ resp [ $ e [ 'field' ] ] ) ) { if ( is_array ( $ param ) ) { $ param = implode ( ', ' , $ param ) ; } $ message = str_replace ( '{param}' , $ param , str_replace ( '{field}' , $ field , $ messages [ $ e [ 'rule' ] ] ) ) ; $ resp [ $ e [ 'field' ] ] = $ message ; } } else { throw new \ Exception ( 'Rule "' . $ e [ 'rule' ] . '" does not have an error message' ) ; } } return $ resp ; }
Process the validation errors and return an array of errors with field names as keys.

@param $convert_to_string

@return array | null (if empty)
Process the validation errors and return an array of errors with field names as keys .