Skip to content

Commit

Permalink
bugfix, Complex数据类型,trim_value配置在validate()逻辑内没有生效
Browse files Browse the repository at this point in the history
  • Loading branch information
yeaha committed May 31, 2017
1 parent 0af8866 commit 6cc8e92
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/DataMapper/Type/Complex.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public function normalizeAttribute(array $attribute)

public function store($value, array $attribute)
{
$trim_values = $attribute['trim_values'] ?? true;

if ($value && $trim_values) {
$value = \Owl\array_trim($value);
}
$value = $this->trimValue($value, $attribute);

return $this->isNull($value) ? null : $value;
}
Expand All @@ -75,9 +71,20 @@ public function isNull($value)
public function validateValue($value, array $attribute)
{
if ($attribute['schema']) {
$value = \Owl\array_trim($value);
$value = $this->trimValue($value, $attribute);

(new \Owl\Parameter\Validator())->execute($value, $attribute['schema']);
}
}

private function trimValue($value, array $attribute)
{
$trim_values = $attribute['trim_values'] ?? true;

if ($value && $trim_values && is_array($value)) {
$value = \Owl\array_trim($value);
}

return $value;
}
}

0 comments on commit 6cc8e92

Please sign in to comment.