mirror of
https://github.com/opdavies/build-configs.git
synced 2025-01-23 02:27:33 +00:00
refactor(validator): remove duplicate constraints
e.g. if a constraint is a choice of strings, that implies the value must be a string so there's no need for an additional type constraint.
This commit is contained in:
parent
15d4fdbd5a
commit
7c17007d84
|
@ -1,5 +1,11 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2023-11-24
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Simplified constraints on properties within the `Config` DTO class.
|
||||||
|
|
||||||
## 2023-11-23
|
## 2023-11-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -8,8 +8,6 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
final class Config
|
final class Config
|
||||||
{
|
{
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -23,7 +21,6 @@ final class Config
|
||||||
|
|
||||||
'type' => new Assert\Required([
|
'type' => new Assert\Required([
|
||||||
new Assert\Choice(choices: ['mariadb', 'mysql']),
|
new Assert\Choice(choices: ['mariadb', 'mysql']),
|
||||||
new Assert\Type('string'),
|
|
||||||
]),
|
]),
|
||||||
|
|
||||||
'version' => new Assert\Required([
|
'version' => new Assert\Required([
|
||||||
|
@ -33,8 +30,6 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $database;
|
public array $database;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -49,8 +44,6 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $dockerCompose;
|
public array $dockerCompose;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -110,16 +103,12 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $dockerfile;
|
public array $dockerfile;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: ['docroot' => new Assert\Choice([null, 'web', 'docroot'])],
|
fields: ['docroot' => new Assert\Choice([null, 'web', 'docroot'])],
|
||||||
)]
|
)]
|
||||||
public array $drupal;
|
public array $drupal;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -139,8 +128,6 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $experimental;
|
public array $experimental;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid()]
|
|
||||||
#[Assert\Collection([
|
#[Assert\Collection([
|
||||||
'ignore' => new Assert\Optional([
|
'ignore' => new Assert\Optional([
|
||||||
new Assert\All([
|
new Assert\All([
|
||||||
|
@ -150,8 +137,6 @@ final class Config
|
||||||
])]
|
])]
|
||||||
public array $git;
|
public array $git;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -170,7 +155,6 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $flake;
|
public array $flake;
|
||||||
|
|
||||||
#[Assert\Type('string')]
|
|
||||||
#[Assert\Choice(choices: ['javascript', 'php', 'typescript'])]
|
#[Assert\Choice(choices: ['javascript', 'php', 'typescript'])]
|
||||||
public string $language;
|
public string $language;
|
||||||
|
|
||||||
|
@ -178,8 +162,6 @@ final class Config
|
||||||
#[Assert\Type('string')]
|
#[Assert\Type('string')]
|
||||||
public string $name;
|
public string $name;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -190,8 +172,6 @@ final class Config
|
||||||
)]
|
)]
|
||||||
public array $node;
|
public array $node;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid]
|
|
||||||
#[Assert\Collection(
|
#[Assert\Collection(
|
||||||
allowExtraFields: false,
|
allowExtraFields: false,
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -259,16 +239,11 @@ final class Config
|
||||||
#[Assert\Type('string')]
|
#[Assert\Type('string')]
|
||||||
public string $projectRoot;
|
public string $projectRoot;
|
||||||
|
|
||||||
#[Assert\NotBlank]
|
|
||||||
#[Assert\Type('string')]
|
|
||||||
#[Assert\Choice(choices: ['astro', 'drupal', 'fractal', 'laravel', 'php-library', 'symfony', 'terraform'])]
|
#[Assert\Choice(choices: ['astro', 'drupal', 'fractal', 'laravel', 'php-library', 'symfony', 'terraform'])]
|
||||||
public string $type;
|
public string $type;
|
||||||
|
|
||||||
#[Assert\Type('array')]
|
|
||||||
#[Assert\Valid()]
|
|
||||||
#[Assert\Collection([
|
#[Assert\Collection([
|
||||||
'type' => new Assert\Required([
|
'type' => new Assert\Required([
|
||||||
new Assert\Type('string'),
|
|
||||||
new Assert\Choice(choices: ['nginx', 'caddy']),
|
new Assert\Choice(choices: ['nginx', 'caddy']),
|
||||||
]),
|
]),
|
||||||
])]
|
])]
|
||||||
|
|
Loading…
Reference in a new issue