public static function validateData(RepositoryInterface $table, array $data, array $user): array
    {
        $fields = Utility::instance()->getSearchableFields($table, $user);
        $fields = array_keys($fields);

        // merge default options
        $data += Options::getDefaults($table);

        if (!empty($data['criteria'])) {
            $data['criteria'] = static::validateCriteria($data['criteria'], $fields);
        }

        $data['display_columns'] = static::validateDisplayColumns($data['display_columns'], $fields);
        $data['sort_by_field'] = static::validateSortByField(
            $data['sort_by_field'],
            $fields,
            $data['display_columns'],
            $table
        );
        $data['sort_by_order'] = static::validateSortByOrder($data['sort_by_order']);
        $data['aggregator'] = static::validateAggregator($data['aggregator']);

        return $data;
    }