From be4325a3dd9becdf9b8fca316776a33e8ed2c2d0 Mon Sep 17 00:00:00 2001 From: Joe Saunderson Date: Wed, 1 May 2024 14:18:15 +0100 Subject: [PATCH] Update InputValidator.php --- src/Validator/InputValidator.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Validator/InputValidator.php b/src/Validator/InputValidator.php index 013fd45b..05bc4740 100644 --- a/src/Validator/InputValidator.php +++ b/src/Validator/InputValidator.php @@ -138,6 +138,12 @@ private function buildValidationTree(ValidationNode $rootObject, iterable $field foreach ($fields as $name => $arg) { $property = $arg['name'] ?? $name; + + if (!array_key_exists($property, $inputData)) { + // This field was not provided in the inputData. Do not attempt to validate it. + continue; + } + $config = static::normalizeConfig($arg['validation'] ?? []); if (isset($config['cascade']) && isset($inputData[$property])) {