protected function validateField($value, ValidationField $field) {
        $validated = false;
        $result = $value = $this->filterField($value, $field, $validated);

        if ($validated) {
            return $result;
        } elseif ($field->getField() instanceof Schema) {
            try {
                $result = $field->getField()->validate($value, $field->getOptions());
            } catch (ValidationException $ex) {
                // The validation failed, so merge the validations together.
                $field->getValidation()->merge($ex->getValidation(), $field->getName());
            }
        } elseif (($value === null || ($value === '' && !$field->hasType('string'))) && ($field->val('nullable') || $field->hasType('null'))) {
            $result = null;
        } else {
            // Look for a discriminator.
            if (!empty($field->val('discriminator'))) {
                $field = $this->resolveDiscriminator($value, $field);
            }

            if ($field !== null) {
                if($field->hasAllOf()) {
                    $result = $this->validateAllOf($value, $field);
                } else {
                    // Validate the field's type.
                    $type = $field->getType();
                    if (is_array($type)) {
                        $result = $this->validateMultipleTypes($value, $type, $field);
                    } else {
                        $result = $this->validateSingleType($value, $type, $field);
                    }

                    if (Invalid::isValid($result)) {
                        $result = $this->validateEnum($result, $field);
                    }
                }
            } else {
                $result = Invalid::value();
            }
        }

        // Validate a custom field validator.
        if (Invalid::isValid($result)) {
            $this->callValidators($result, $field);
        }

        return $result;
    }