mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-02 13:57:33 +00:00
chore: allow for missing fields
This commit is contained in:
parent
8b2181525d
commit
eeeb70df14
|
@ -18,41 +18,50 @@ final class ConfigurationValidator implements ValidatorInterface
|
||||||
|
|
||||||
$constraint = new Assert\Collection(
|
$constraint = new Assert\Collection(
|
||||||
[
|
[
|
||||||
'name' => [
|
'fields' => [
|
||||||
new Assert\NotNull(),
|
'name' => [
|
||||||
new Assert\Type('string'),
|
new Assert\NotNull(),
|
||||||
new Assert\Length(['min' => 1]),
|
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' => [
|
'allowExtraFields' => false,
|
||||||
new Assert\NotNull(),
|
'allowMissingFields' => true,
|
||||||
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(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
return $validator->validate($configurationData, $constraint, $groups);
|
return $validator->validate(
|
||||||
|
constraints: $constraint,
|
||||||
|
groups: $groups,
|
||||||
|
value: $configurationData,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue