Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
filx validator has no effect on not required param.
  • Loading branch information
dyf991645 authored Apr 24, 2020
1 parent cfc0927 commit 18aeabf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/validator/src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ protected function validateDefaultValidator(array $data, array $validator, array
{
$properties = $validator['properties'] ?? [];
foreach ($properties as $propName => $property) {
/* @var IsString|IsInt|IsBool|IsFloat $type */
$type = $property['type']['annotation'] ?? null;
$default = $property['type']['default'] ?? null;
$annotations = $property['annotations'] ?? [];
if ($type === null) {
continue;
}

$name = $type->getName();
$propName = empty($name) ? $propName : $name;

if (!empty($fields) && !in_array($propName, $fields, true)) {
continue;
}
Expand All @@ -190,17 +201,6 @@ protected function validateDefaultValidator(array $data, array $validator, array
continue;
}

/* @var IsString|IsInt|IsBool|IsFloat $type */
$type = $property['type']['annotation'] ?? null;
$default = $property['type']['default'] ?? null;
$annotations = $property['annotations'] ?? [];
if ($type === null) {
continue;
}

$name = $type->getName();
$propName = empty($name) ? $propName : $name;

// Default validate item(Type) and other item
$data = $this->validateDefaultItem($data, $propName, $type, $default);
foreach ($annotations as $annotation) {
Expand Down

0 comments on commit 18aeabf

Please sign in to comment.