diff --git a/src/Scan/ScanAnnotation.php b/src/Scan/ScanAnnotation.php index afaa386..c098c33 100644 --- a/src/Scan/ScanAnnotation.php +++ b/src/Scan/ScanAnnotation.php @@ -121,9 +121,6 @@ protected function generateValidation(string $className, string $fieldName) if ($annotation instanceof BaseValidation) { $validationArr[] = $annotation; } - if ($annotation instanceof ApiModelProperty && ! empty($annotation->value)) { - ValidationManager::setAttributes($className, $fieldName, $annotation->value); - } } $ruleArray = []; foreach ($validationArr as $validation) { @@ -138,7 +135,14 @@ protected function generateValidation(string $className, string $fieldName) $key = $fieldName . '.' . $messagesRule; ValidationManager::setMessages($className, $key, $validation->messages); } - ! empty($ruleArray) && ValidationManager::setRule($className, $fieldName, $ruleArray); + if (! empty($ruleArray)) { + ValidationManager::setRule($className, $fieldName, $ruleArray); + foreach ($annotationArray as $annotation) { + if ($annotation instanceof ApiModelProperty && ! empty($annotation->value)) { + ValidationManager::setAttributes($className, $fieldName, $annotation->value); + } + } + } } protected function getTypeName(ReflectionProperty $rp): string