diff --git a/migrations/Version20241121135118.php b/migrations/Version20241121135118.php new file mode 100644 index 0000000..ad42559 --- /dev/null +++ b/migrations/Version20241121135118.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE subnet CHANGE next_server next_server VARCHAR(255) DEFAULT NULL, CHANGE boot_file_name boot_file_name VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE subnet CHANGE next_server next_server VARCHAR(255) NOT NULL, CHANGE boot_file_name boot_file_name VARCHAR(255) NOT NULL'); + } +} diff --git a/src/Dto/Input/SubnetInput.php b/src/Dto/Input/SubnetInput.php index 98fed68..59d9726 100644 --- a/src/Dto/Input/SubnetInput.php +++ b/src/Dto/Input/SubnetInput.php @@ -17,21 +17,21 @@ final class SubnetInput public ?string $name = null; #[Assert\NotBlank(message: 'validators.subnet.netmask.not_blank')] + #[Assert\Ip(message: 'validators.subnet.netmask.invalid')] #[Groups(['subnet:write'])] #[ApiProperty(description: 'The netmask of the subnet', example: "")] public ?string $netmask = null; #[Assert\NotBlank(message: 'validators.subnet.ip_address.not_blank')] + #[Assert\Ip(message: 'validators.subnet.ip_address.invalid')] #[Groups(['subnet:write'])] #[ApiProperty(description: 'The ip address of the subnet', example: "")] public ?string $ipAddress = null; - #[Assert\NotBlank(message: 'validators.subnet.next_server.not_blank')] #[Groups(['subnet:write'])] #[ApiProperty(description: 'The next server of the subnet', example: "")] public ?string $nextServer = null; - #[Assert\NotBlank(message: 'validators.subnet.boot_file_name.not_blank')] #[Groups(['subnet:write'])] #[ApiProperty(description: 'The boot file name of the subnet', example: "")] public ?string $bootFileName = null; diff --git a/src/Dto/Output/ClientOutput.php b/src/Dto/Output/ClientOutput.php index d751f6d..818fbac 100644 --- a/src/Dto/Output/ClientOutput.php +++ b/src/Dto/Output/ClientOutput.php @@ -66,7 +66,7 @@ final class ClientOutput extends AbstractOutput #[Groups(['client:read', 'organizational-unit:read'])] public ?array $position = ['x' => 0, 'y' => 0]; - #[Groups(['client:read'])] + #[Groups(['client:read', 'organizational-unit:read', 'pxe-template:read', 'trace:read', 'subnet:read'])] public ?string $status = ''; #[Groups(['client:read'])] diff --git a/src/Dto/Output/SubnetOutput.php b/src/Dto/Output/SubnetOutput.php index e112d82..31ef891 100644 --- a/src/Dto/Output/SubnetOutput.php +++ b/src/Dto/Output/SubnetOutput.php @@ -22,10 +22,10 @@ final class SubnetOutput extends AbstractOutput public string $ipAddress; #[Groups(['subnet:read'])] - public string $nextServer; + public ?string $nextServer = null; #[Groups(['subnet:read'])] - public string $bootFileName; + public ?string $bootFileName = null; #[Groups(['subnet:read'])] public array $clients; diff --git a/translations/validators.en.yaml b/translations/validators.en.yaml index 2ed5bc8..03f3bd3 100644 --- a/translations/validators.en.yaml +++ b/translations/validators.en.yaml @@ -61,9 +61,7 @@ validators: not_blank: 'The name should not be blank.' ip_address: not_blank: 'The IP should not be blank.' + invalid: 'The IP address {{ value }} is not valid.' netmask: not_blank: 'The netmask should not be blank.' - boot_file_name: - not_blank: 'The boot file name should not be blank.' - next_server: - not_blank: 'The next server should not be blank.' \ No newline at end of file + invalid: 'The netmask {{ value }} is not valid.' diff --git a/translations/validators.es.yaml b/translations/validators.es.yaml index a6bbf00..0f307d3 100644 --- a/translations/validators.es.yaml +++ b/translations/validators.es.yaml @@ -56,9 +56,7 @@ validators: not_blank: 'El nombre no debería estar vacío.' ip_address: not_blank: 'La dirección IP no debería estar vacía.' + invalid: 'La dirección IP {{ value }} no es válida.' netmask: not_blank: 'La máscara de red no debería estar vacía.' - boot_file_name: - not_blank: 'El nombre del archivo de arranque no debería estar vacío.' - next_server: - not_blank: 'El servidor no debería estar vacío.' \ No newline at end of file + invalid: 'La máscara de red {{ value }} no es válida.' \ No newline at end of file