diff --git a/src/Validator/ConfigurationValidator.php b/src/Validator/ConfigurationValidator.php index dd9c8ca..377b2c9 100644 --- a/src/Validator/ConfigurationValidator.php +++ b/src/Validator/ConfigurationValidator.php @@ -18,41 +18,50 @@ final class ConfigurationValidator implements ValidatorInterface $constraint = new Assert\Collection( [ - 'name' => [ - new Assert\NotNull(), - new Assert\Type('string'), - new Assert\Length(['min' => 1]), + 'fields' => [ + 'name' => [ + new Assert\NotNull(), + new Assert\Type('string'), + new Assert\Length(['min' => 1]), + ], + + 'language' => [ + new Assert\NotNull(), + new Assert\Type('string'), + new Assert\Choice(['php']), + ], + + 'type' => [ + new Assert\NotNull(), + new Assert\Type('string'), + new Assert\Choice(['drupal-project', 'php-library']), + ], + + 'database' => new Assert\Optional(), + + 'drupal' => new Assert\Optional(), + + 'docker-compose' => new Assert\Optional(), + + 'dockerfile' => new Assert\Optional(), + + // TODO: this should be a boolean if present. + 'justfile' => new Assert\Optional(), + + 'php' => new Assert\Optional(), + + 'web' => new Assert\Optional(), ], - 'language' => [ - new Assert\NotNull(), - new Assert\Type('string'), - new Assert\Choice(['php']), - ], - - 'type' => [ - new Assert\NotNull(), - new Assert\Type('string'), - new Assert\Choice(['drupal-project', 'php-library']), - ], - - 'database' => new Assert\Optional(), - - 'drupal' => new Assert\Optional(), - - 'docker-compose' => new Assert\Optional(), - - 'dockerfile' => new Assert\Optional(), - - // TODO: this should be a boolean if present. - 'justfile' => new Assert\Optional(), - - 'php' => new Assert\Optional(), - - 'web' => new Assert\Optional(), + 'allowExtraFields' => false, + 'allowMissingFields' => true, ], ); - return $validator->validate($configurationData, $constraint, $groups); + return $validator->validate( + constraints: $constraint, + groups: $groups, + value: $configurationData, + ); } }