src/Resources/BaseDbTableResource.php
protected function validateRecord($record, $filter_info, $for_update = false, $old_record = null)
    {
        $record = array_change_key_case($record, CASE_LOWER);
        $filters = array_get($filter_info, 'filters');

        if (empty($filters) || empty($record)) {
            return;
        }

        $combiner = array_get($filter_info, 'filter_op', 'and');
        foreach ($filters as $filter) {
            $filterField = strtolower(array_get($filter, 'name'));
            $operator = array_get($filter, 'operator');
            $filterValue = array_get($filter, 'value');
            $filterValue = static::interpretFilterValue($filterValue);
            $foundInRecord = (is_array($record)) ? array_key_exists($filterField, $record) : false;
            $recordValue = array_get($record, $filterField);

            $old_record = (array)$old_record;
            $foundInOld = array_key_exists($filterField, $old_record);
            $oldValue = array_get($old_record, $filterField);
            $compareFound = ($foundInRecord || ($for_update && $foundInOld));
            $compareValue = $foundInRecord ? $recordValue : ($for_update ? $oldValue : null);

            $reason = null;
            if ($for_update && !$compareFound) {
                // not being set, filter on update will check old record
                continue;
            }

            if (!static::compareByOperator($operator, $compareFound, $compareValue, $filterValue)) {
                $reason = "Denied access to some of the requested fields.";
            }

            switch (strtolower($combiner)) {
                case 'and':
                    if (!empty($reason)) {
                        // any reason is a good reason to bail
                        throw new ForbiddenException($reason);
                    }
                    break;
                case 'or':
                    if (empty($reason)) {
                        // at least one was successful
                        return;
                    }
                    break;
                default:
                    throw new InternalServerErrorException('Invalid server configuration detected.');
            }
        }
    }
protected function validateRecord($record, $filter_info, $for_update = false, $old_record = null)
    {
        $record = array_change_key_case($record, CASE_LOWER);
        $filters = array_get($filter_info, 'filters');

        if (empty($filters) || empty($record)) {
            return;
        }

        $combiner = array_get($filter_info, 'filter_op', 'and');
        foreach ($filters as $filter) {
            $filterField = strtolower(array_get($filter, 'name'));
            $operator = array_get($filter, 'operator');
            $filterValue = array_get($filter, 'value');
            $filterValue = static::interpretFilterValue($filterValue);
            $foundInRecord = (is_array($record)) ? array_key_exists($filterField, $record) : false;
            $recordValue = array_get($record, $filterField);

            $old_record = (array)$old_record;
            $foundInOld = array_key_exists($filterField, $old_record);
            $oldValue = array_get($old_record, $filterField);
            $compareFound = ($foundInRecord || ($for_update && $foundInOld));
            $compareValue = $foundInRecord ? $recordValue : ($for_update ? $oldValue : null);

            $reason = null;
            if ($for_update && !$compareFound) {
                // not being set, filter on update will check old record
                continue;
            }

            if (!static::compareByOperator($operator, $compareFound, $compareValue, $filterValue)) {
                $reason = "Denied access to some of the requested fields.";
            }

            switch (strtolower($combiner)) {
                case 'and':
                    if (!empty($reason)) {
                        // any reason is a good reason to bail
                        throw new ForbiddenException($reason);
                    }
                    break;
                case 'or':
                    if (empty($reason)) {
                        // at least one was successful
                        return;
                    }
                    break;
                default:
                    throw new InternalServerErrorException('Invalid server configuration detected.');
            }
        }
    }
@param array $record
@param array $filter_info
@param bool  $for_update
@param array $old_record

@throws \Exception