Skip to content

Commit

Permalink
空规则判断
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2066 committed Feb 18, 2022
1 parent 969d89c commit 38280c7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Scan/ScanAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 38280c7

Please sign in to comment.