Get the errors for a given field

@param string $field A dot separated path to check errors on.
@return array An array of errors, an empty array will be returned when the
context has no errors.
177556
public function error($field)
    {
        if (empty($this->_context['errors'])) {
            return [];
        }

        return (array)Hash::get($this->_context['errors'], $field);
    }
700657
public function getErrors($fieldName=null)
    {
        if ($fieldName === null) {
            return $this->errors;
        }

        if (isset($this->errors[$fieldName])) {
            return $this->errors[$fieldName];
        }

        return [];
    }
50461
public function getFieldDefinition($field)
    {
        if (isset($this->definition[$field])) {
            return $this->definition[$field];
        }
        if (isset($this->definition['fields'][$field])) {
            return $this->definition['fields'][$field];
        }
        return null;
    }
170244
private function getValues(array $field)
    {
        if ($field['type'] !== 'select') {
            return null;
        }
        $field = Bag::from($field);

        // Get the appropriate values
        return is_string($field->get('values', [])) ? $this->getEntityValues($field) : $this->getYamlValues($field);
    }
758526
public function getFileList($field = null)
    {
        $dir = $this->getFilePath($field, '');
        if (!file_exists($dir) || !is_dir($dir)) {
            return [];
        }
        return array_diff(scandir($dir), ['.', '..']);
    }
1335807
private function getFieldValue($field)
    {
        return isset($this->values[$field]) ? $this->values[$field] : null;
    }
486851
public function get_field_raw( $field ) {
		if ( array_key_exists( $field, $this->prop( 'fields' ) ) ) {
			return $this->prop( 'fields' )[ $field ];
		}

		return null;
	}
472686
final public function getRowFieldValue($field)
    {

        //If value exists;
        if (array_key_exists($field, $this->schema)) {
            return $this->schema[$field]->Value;
        }
        return null;
    }
881008
private function fieldValues($fields)
    {
        $result = [];
        foreach ($fields as $field) {
            if (!$this->test && (isset($field->test_only) ? $field->test_only : false)) {
                // Skip this field as it is for test mode only.
                continue;
            }
            $key = isset($field->key) ? trim($field->key) : '';
            if ('' === $key) {
                // Skip if we have an empty key.
                continue;
            }
            // Loop through value sources till a non-empty tokenized result is found.
            $valueSources = ['value', 'default_value'];
            if ($this->test) {
                $valueSources = ['test_value', 'value', 'default_value'];
            }
            $value = null;
            foreach ($valueSources as $valueSource) {
                if (isset($field->{$valueSource}) && null !== $field->{$valueSource} && '' !== $field->{$valueSource}) {
                    $value = $this->tokenHelper->render($field->{$valueSource});
                    if (null !== $value && '' !== $value) {
                        break;
                    }
                }
            }
            if (null === $value || '' === $value) {
                // The field value is empty and not 0/false.
                if (true === (isset($field->required) ? $field->required : false)) {
                    // The field is required. Abort.
                    throw new ContactClientException(
                        'A required Client file field "'.$field->key.'" is empty based on "'.$field->value.'"',
                        0,
                        null,
                        Stat::TYPE_FIELDS,
                        false,
                        $field->key
                    );
                }
            }
            $result[$key] = $value;
        }

        return $result;
    }
137810
private function extractErrors($error)
    {
        $messages = [];

        foreach ($error as $key => $errors)
        {
            // If error is a MessageBag, extract errors
            if ($errors instanceof MessageBag) return $this->extractErrors($errors->toArray());

            // If we have an array of errors preserve key
            if (is_array($errors))
            {
                $messages[$key] = $this->extractErrors($errors);
                continue;
            }

            // We must be down to a single error, just return it
            return $errors;
        }

        return $messages;
    }
818677
public function getMessages($field = null)
    {
        $context = $this->_context;

        if ($field) {
            return isset($context->messages[$field]) ? $context->messages[$field] : [];
        } else {
            return $context->messages;
        }
    }
345253
public function attributes($field)
    {
        $parts = explode('.', $field);
        $table = $this->_getTable($parts);
        $column = (array)$table->getSchema()->getColumn(array_pop($parts));
        $whitelist = ['length' => null, 'precision' => null];

        return array_intersect_key($column, $whitelist);
    }
702174
protected function getFieldClientOptions($field)
    {
        $attribute = Html::getAttributeName($field->attribute);
        if (!in_array($attribute, $field->model->activeAttributes(), true)) {
            return [];
        }

        $clientValidation = $field->isClientValidationEnabled();
        $ajaxValidation = $field->isAjaxValidationEnabled();

        if ($clientValidation) {
            $validators = [];
            foreach ($field->model->getActiveValidators($attribute) as $validator) {
                /* @var $validator \yii\validators\Validator */
                if (!$validator->enableClientValidation) {
                    continue;
                }

                $js = $validator->clientValidateAttribute($field->model, $attribute, $field->form->getView());
                if ($js === null || $js === '') {
                    $js = $this->buildClientValidator($validator, $field->model, $attribute, $field->form->getView());
                }

                if ($js !== '') {
                    if ($validator->whenClient !== null) {
                        $js = "if (({$validator->whenClient})(attribute, value)) { $js }";
                    }
                    $validators[] = $js;
                }
            }
        }

        if (!$ajaxValidation && (!$clientValidation || empty($validators))) {
            return [];
        }

        $options = [];

        $inputID = $field->getInputId();
        $options['id'] = Html::getInputId($field->model, $field->attribute);
        $options['name'] = $field->attribute;

        $options['container'] = $field->selectors['container'] ?? ".field-$inputID";
        $options['input'] = $field->selectors['input'] ?? "#$inputID";
        if (isset($field->selectors['error'])) {
            $options['error'] = $field->selectors['error'];
        } elseif (isset($field->errorOptions['class'])) {
            $options['error'] = '.'.implode('.', preg_split('/\s+/', $field->errorOptions['class'], -1, PREG_SPLIT_NO_EMPTY));
        } else {
            $options['error'] = $field->errorOptions['tag'] ?? 'span';
        }

        $options['encodeError'] = !isset($field->errorOptions['encode']) || $field->errorOptions['encode'];
        if ($ajaxValidation) {
            $options['enableAjaxValidation'] = true;
        }
        foreach (['validateOnChange', 'validateOnBlur', 'validateOnType', 'validationDelay'] as $name) {
            $options[$name] = $field->$name ?? $field->form->$name;
        }

        if (!empty($validators)) {
            $options['validate'] = new JsExpression('function (attribute, value, messages, deferred, $form) {'.implode('', $validators).'}');
        }

        if ($field->addAriaAttributes === false) {
            $options['updateAriaInvalid'] = false;
        }

        return $options;
    }
1186509
public function messages($field)
    {
        return (isset($this->data[$field]) && $messages = $this->data[$field]['messages']) ? $messages : array();
    }
1028485
public function getValue($field) {
        if (is_array($this->values)) {
            return isset($this->values[$field]) ? $this->values[$field] : null;
        }
        if (is_object($this->values)) {
            return $this->values->$field;
        }
        return null;
    }
138952
final public function getValidationRule($field): array
    {
        $rules = $this->rules();
        $response = [];

        foreach ($rules as $rule) {
            if (Any::isArray($rule[0])) { // 2 or more rules [['field1', 'field2'], 'filter', 'filter_argv']
                foreach ($rule[0] as $tfield) {
                    if ($tfield == $field) {
                        $response[$rule[1]] = $rule[2];
                    } // ['min_length' => 1, 'required' => null]
                }
            } else { // 1 rule ['field1', 'filter', 'filter_argv']
                if ($rule[0] === $field) {
                    $response[$rule[1]] = $rule[2];
                }
            }
        }

        return $response;
    }
654580
function errors($fieldname) {
		if ($fieldname == null) {
			return null;
		}
		else { # field errors
			if ($this->errors !== null) {
				if (isset($this->errors[$fieldname])) {
					return $this->errors[$fieldname];
				}
				else { # not set
					return null;
				}
			}
		}
	}