Checks if Resource has all fields passed

@param string[] $fields List of fields to test

@return true   On success
@return string On failure, with error message
5564
public function hasFields(array $fields)
    {
        try {
            $this->model_class::checkUnknownColumn($fields);
        } catch (UnknownColumnException $e) {
            return "Resource '$this->name' "
                . explode(' ', $e->getMessage(), 2)[1];
        }
        return true;
    }
260109
public function inError(string $field): bool
    {
        foreach ($this->_errors as $item) {
            if ($field === $item['name']) {
                return true;
            }
        }
        return false;
    }
1190863
public function mremove(array $fields)
    {
        $removed = 0;

        foreach ($fields as $field) {
            $removed += $this->remove($field);
        }

        return $removed;
    }
13931
private static function getFieldNameArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $names = array();

        foreach ($fields as &$field) {
            $names[] = $field->name;
        }

        return $names;
    }
983938
protected function getValidationRules(array $fields)
    {
        $validations = '';

        foreach ($fields as $field) {

            $rules = $field->getValidationRule();
            $customRules = $this->extractCustomValidationRules($rules);

            if (!empty($rules)) {

                if ($field->isFile()) {
                    $rules = array_filter($rules, function ($rule) {
                        return $rule != 'required';
                    });
                }

                if (!empty($customRules) || $field->isFile()) {

                    $standardRules = array_diff($rules, $customRules);
                    $shortCustomRules = $this->extractCustomValidationShortName($customRules);

                    $wrappedRules = array_merge(Helpers::wrapItems($standardRules), $shortCustomRules);
                    $validations .= sprintf("        '%s' => [%s],\n    ", $field->name, implode(',', $wrappedRules));
                } else {
                    $validations .= sprintf("        '%s' => '%s',\n    ", $field->name, implode('|', $rules));
                }
            }
        }

        return $validations;
    }
72021
public function isValid(array $requiredFields = array()) {
        // check if all values required to send the mail are set
        if (empty($this->_params['body'])
            || empty($this->_params['from'])
            || empty($this->_params['to'])
            || empty($this->_params['subject'])
        ) {
            $this->addError('Not all required mail parameters were given.');
            return false;
        }

        // check that at least 1 second passed from form rendering to form submit
        if (array_key_exists(self::TIMESTAMP_KEY, $this->_postParams)
            && time()-$this->_postParams[self::TIMESTAMP_KEY] <= 1
        ) {
            $this->addError('Timestamp difference is less than or equal to 1 second.');
            return false;
        }

        // check if the honeypot was filled
        if (array_key_exists(self::HONEYPOT_KEY, $this->_postParams)
            && !empty($this->_postParams[self::HONEYPOT_KEY])
        ) {
            $this->addError('Honeypot was filled.');
            return false;
        }

        // check if all required fields were filled
        foreach ($requiredFields as $field) {
            if (empty($this->_postParams[$field])) {
                $this->addError('Required field ' . $field . ' is empty.');
                return false;
            }
        }
        return true;
    }
973232
private function prepareFields(array $fields)
    {
        $include = null;
        foreach ($fields as $key => $type) {
            $type = (bool) $type;
            if (null === $include) {
                $include = $type;
            }
            if ($type !== $include) {
                PersisterException::badRequest('Field projection mismatch. You cannot both exclude and include fields.');
            }
            $fields[$key] = $type;
        }
        return [$fields, $include];
    }
193629
public function has_all(array $keys) {
        foreach ($keys as $key) {
            if (!$this->has($key)) {
                return false;
            }
        }
        return true;
    }
1105654
public function allWithPaging($fields = null, $limit = null)
    {
        return $this->withPaging(null, $limit)->all($fields, $limit);
    }
238893
protected function getFormRules(array $fields)
    {
        $rules = [];

        foreach ($fields as $field) {
            /** @var FieldTypeInterface $field */
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }
1324618
protected function updateInternal(array $fields = [])
    {
        $values = $this->getChangedAttributes($fields);
        if (empty($values)) {
            return true;
        }

        $rows = $this->objects()
            ->filter($this->getPrimaryKeyValues())
            ->update($values);

        foreach ($values as $name => $value) {
            $this->setAttribute($name, $value);
        }
        $this->updateRelated();

        return $rows >= 0;
    }
927183
public function validateAsRequiredFields(array $fields) {
		foreach ($fields as $v) {
			$options = $this->fields[$v];
			$options['options']['required'] = true;
			$this->validateRequiredOneField($this->values[$v], $v, $options);
		}
	}
652937
public function hasFields()
    {
        if ($this->hasProperty()) {
            $property = $this->property();
            if ($property instanceof StorablePropertyInterface) {
                return (count($property->fieldNames()) > 0);
            } else {
                return true;
            }
        }

        return false;
    }
604125
public function only($fields)
    {
        if ( count(func_get_args()) > 1 ) {
            $fields = func_get_args();
        }

        if ( !is_array($fields) ) {
            $fields = [$fields];
        }

        $result = [];
        foreach ($this->all() as $fieldName => $value) {
            if ( in_array($fieldName, $fields) ) {
                $result[ $fieldName ] = $value;
            }
        }

        return $result;
    }
1032286
public function fieldExists($field, $table) {
        $fieldLists = $this->query("DESC " . $this->getPrefix() . $table);
        foreach ($fieldLists as $f) {
            if (strtolower($f['Field']) == strtolower($field)) {
                return TRUE;
            }
        }
        return FALSE;
    }
324836
protected function buildAllFields(array $fields) : array
    {
        foreach ($fields as $key => $field) {
            if ($field instanceof FieldBuilderBase) {
                $fields[$key] = $field->build();
            }
        }

        return $fields;
    }
208063
private function isValidFields(array $fields): void
    {
        $allowedFields = $this->getAllowedFields();
        foreach ($fields as $field) {
            if (!\in_array($field, $allowedFields, true)) {
                throw new InvalidKeyException(sprintf(
                    '%s is not a valid value. fields must only contain "%s".',
                    $field,
                    implode(', ', $allowedFields)
                ));
            }
        }
    }