Skip to content

Commit 0898833

Browse files
committed
short circuit on false result
1 parent 90bc821 commit 0898833

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Type/ErrorType/InputObjectValidationErrorType.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public function validate(array $field, mixed $value, array $settings): array
4343
{
4444
$res = [];
4545
if (is_callable($field['validate'] ?? null)) {
46-
$result = static::_formatValidationResult($field['validate']($value));
46+
$rawResult = $field['validate']($value);
47+
if ($rawResult === false) {
48+
return $res;
49+
}
50+
$result = static::_formatValidationResult($rawResult);
4751

4852
if (isset($result) && $result[static::CODE_NAME] !== 0) {
4953
$res = $result;

src/Type/ErrorType/ListOfValidationErrorType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ protected function _validateListOfType(array $config, array $value, array $path,
115115
{
116116
$res = [];
117117
$validate = $this->config[static::ITEMS_NAME]['validate'] ?? null;
118+
119+
if ($validate === false) {
120+
return $res;
121+
}
122+
118123
$wrappedType = $config['type']->getWrappedType();
119124
$wrappedErrorType = $this->config['fields']['_' . static::ITEMS_NAME]['type'] ?? null;
120125
$wrappedErrorType = $wrappedErrorType?->getWrappedType();

0 commit comments

Comments
 (0)