protected static function validate($data, $full)
    {
        $columns = array_keys($data);

        /*
         * Check missing columns
         */
        if ($full) {
            $missing = array_diff(static::getRequiredColumns(), $columns);
            if (!empty($missing)) {
                throw new MissingColumnException(static::class, $missing);
            }
        }

        static::checkUnknownColumn($columns);

        /*
         * Expanded validation
         */
        $result = static::onValidate($data);
        if ($result === false) {
            $message = static::class . ' has invalid data';
            throw new \UnexpectedValueException($message);
        } elseif (is_array($result)) {
            $data = (empty(Utils::arrayUniqueDiffKey($data, $result)))
                ? $result
                : array_replace($data, $result);
        }

        return $data;
    }
protected static function validate($data, $full)
    {
        $columns = array_keys($data);

        /*
         * Check missing columns
         */
        if ($full) {
            $missing = array_diff(static::getRequiredColumns(), $columns);
            if (!empty($missing)) {
                throw new MissingColumnException(static::class, $missing);
            }
        }

        static::checkUnknownColumn($columns);

        /*
         * Expanded validation
         */
        $result = static::onValidate($data);
        if ($result === false) {
            $message = static::class . ' has invalid data';
            throw new \UnexpectedValueException($message);
        } elseif (is_array($result)) {
            $data = (empty(Utils::arrayUniqueDiffKey($data, $result)))
                ? $result
                : array_replace($data, $result);
        }

        return $data;
    }
protected static function validate ( $ data , $ full ) { $ columns = array_keys ( $ data ) ; /*
         * Check missing columns
         */ if ( $ full ) { $ missing = array_diff ( static :: getRequiredColumns ( ) , $ columns ) ; if ( ! empty ( $ missing ) ) { throw new MissingColumnException ( static :: class , $ missing ) ; } } static :: checkUnknownColumn ( $ columns ) ; /*
         * Expanded validation
         */ $ result = static :: onValidate ( $ data ) ; if ( $ result === false ) { $ message = static :: class . ' has invalid data' ; throw new \ UnexpectedValueException ( $ message ) ; } elseif ( is_array ( $ result ) ) { $ data = ( empty ( Utils :: arrayUniqueDiffKey ( $ data , $ result ) ) ) ? $ result : array_replace ( $ data , $ result ) ; } return $ data ; }
Tells if the model has valid data

It may change the data to remove unwanted content

@param mixed[] $data Data to be validated
@param boolean $full If $data is supposed to contain all columns
(optional columns are ignored)

@return mixed[] Valid data

@throws MissingColumnException
@throws UnknownColumnException @see checkUnknownColumn()
@throws \UnexpectedValueException If Invalid data is found
Tells if the model has valid data