Get a validation error for a given field.

@param string $field Name of the field.
@return string|null A validation error for the field. Null is no validation error found.
171055
public function getValidationError($field)
    {
        // break apart path
        $crumbs = explode('.', $field);

        // resolve path recursively
        $cur = &$this->_validationErrors;
        while ($crumb = array_shift($crumbs)) {
            if (array_key_exists($crumb, $cur)) {
                $cur = &$cur[$crumb];
            } else {
                return null;
            }
        }

        // return current value
        return $cur;
    }
540510
public static function getField($field)
    {
        return isset(self::$fields[$field]) ? self::$fields[$field] : null;
    }
448929
public function getValFormatted($field)
    {
        if ($this->validate($field)) {
            $value = $field->valRaw();
            $dateArray = $this->getDateArray($value);
            return \sprintf('%04d-%02d-%02d', $dateArray['year'], $dateArray['mon'], $dateArray['mday']);
        }
        return null;
    }
1095484
public function getRequiredMessage($field)
    {
        if (!isset($this->_fields[$field])) {
            return null;
        }

        $defaultMessage = 'This field is required';
        if ($this->_useI18n) {
            $defaultMessage = __d('cake', 'This field is required');
        }

        return isset($this->_presenceMessages[$field])
            ? $this->_presenceMessages[$field]
            : $defaultMessage;
    }
939984
public function getFieldInput($field)
    {
        $model = ClassRegistry::init($this->usersModel);

        switch ($field) {
            case 'username':
                $username = trim($this->in('Username:'));

                if (!$username) {
                    $username = $this->getFieldInput($field);

                } else {
                    $result = $model->find('count', array(
                        'conditions' => array($model->alias . '.' . $this->userFields['username'] => $username)
                    ));

                    if ($result) {
                        $this->out('<error>Username already exists, please try again</error>');
                        $username = $this->getFieldInput($field);
                    }
                }

                return $username;
                break;

            case 'email':
                $email = trim($this->in('Email:'));

                if (!$email) {
                    $email = $this->getFieldInput($field);

                } else if (!Validation::email($email)) {
                    $this->out('<error>Invalid email address, please try again</error>');
                    $email = $this->getFieldInput($field);

                } else {
                    $result = $model->find('count', array(
                        'conditions' => array($model->alias . '.' . $this->userFields['email'] => $email)
                    ));

                    if ($result) {
                        $this->out('<error>Email already exists, please try again</error>');
                        $email = $this->getFieldInput($field);
                    }
                }

                return $email;
                break;

            // Password, others...
            default:
                $value = trim($this->in(sprintf('%s:', Inflector::humanize($field))));

                if (!$value) {
                    $value = $this->getFieldInput($field);
                }

                return $value;
                break;
        }
    }
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;
    }
15614
public function errors($field = null)
    {
        if ($field !== null) {
            return isset($this->_errors[$field]) ? $this->_errors[$field] : false;
        }

        return $this->_errors;
    }
628636
public function getFieldType($field)
    {
        $definition = $this->getFieldDefinition($field);
        if ($definition && isset($definition['type'])) {
            return $definition['type'];
        }
    }
1111079
public function getValFormatted($field)
    {
        $val = $field->valRaw();
        $val = \preg_replace('/[^\d.-]/', '', $val);
        $val = \strlen($val)
            ? \sprintf('%.2f', $val)
            : null;
        return $val === null
            ? null
            : '$'.\number_format($val, 2);
    }
487129
public function getFieldErrors(string $field): array {
        if (empty($this->errors[$field])) {
            return [];
        } else {
            $result = [];
            foreach ($this->errors[$field] as $error) {
                $result[] = $this->pluckError($error + ['field' => $field]);
            }
            return $result;
        }
    }
325394
public function getFieldErrors($field) {
		$existing = array_key_get($this->errors['fields'], $field['options']['name']);
		if (!empty($existing)) {
			$result = [
				'type' => null,
				'message' => '',
				'counters' => []
			];
			$sorted = [
				'danger' => [],
				'warning' => [],
				'success' => [],
				'info' => []
			];
			$types = array_keys($existing);
			if (in_array('danger', $types)) {
				$result['type'] = 'danger';
			} else {
				$temp = current($types);
				$result['type'] = $temp;
			}
			// generating text messages
			foreach ($existing as $k => $v) {
				foreach ($v as $k2 => $v2) {
					$result['counters'][$k] = ($result[$k] ?? 0) + 1;
					$sorted[$k][$k2] = $v2;
				}
			}
			foreach ($sorted as $k => $v) {
				if (empty($v)) continue;
				foreach ($v as $k2 => $v2) {
					$result['message'].= \HTML::text(['tag' => 'div', 'class' => 'numbers_field_error_messages', 'data-field_value_hash' => $k2, 'type' => $k, 'value' => $v2]);
				}
			}
			return $result;
		}
		return null;
	}
527138
public function validated($field = null, $default = false)
	{
		if ($field === null)
		{
			return $this->validated;
		}

		return array_key_exists($field, $this->validated) ? $this->validated[$field] : $default;
	}
662809
public function type($field)
    {
        if (!is_array($this->_context['schema'])) {
            return null;
        }

        $schema = Hash::get($this->_context['schema'], $field);
        if ($schema === null) {
            $schema = Hash::get($this->_context['schema'], $this->stripNesting($field));
        }

        return isset($schema['type']) ? $schema['type'] : null;
    }
605387
public function url($field)
    {
        return (filter_var(trim($this->get($field)), FILTER_VALIDATE_URL) !== false) ?: $this->error($field,
            __FUNCTION__);
    }
798208
public function first($field = '')
    {
        if (isset($this->errorMessages[$field])) {
            $message = reset($this->errorMessages[$field]);
        } else {
            $firstMessages = $this->firsts();
            $message = reset($firstMessages);
        }

        return $message;
    }
957144
public function getMessage($field)
    {
        $identifier = ($field instanceof FieldInterface) ? $field->getFieldElementName() : $field;
        foreach ($this->getList() as $error) {
            $field = $error->getField();
            if (is_object($field) && $field->getFieldElementName() == $identifier) {
                return $error->getMessage();
            }
        }

        return false;
    }
25766
public function validateField(Field $field)
    {
        if (false === $this->fieldWasValidated($field)) {
            $this->checkFieldActivation($field);

            if (false === $this->result->fieldIsDeactivated($field)) {
                $this->markFieldAsValidated($field);

                // Looping on the field's validation settings...
                foreach ($field->getValidation() as $validation) {
                    if ($this->result->validationIsDeactivated($validation)) {
                        continue;
                    }

                    $validatorResult = $this->processFieldValidation($field, $validation);

                    // Breaking the loop if an error occurred: we stop the validation process for the current field.
                    if ($validatorResult->hasErrors()) {
                        break;
                    }
                }
            }
        }
    }