Skip to content

Commit

Permalink
Optional validation added.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilcosdu committed May 6, 2024
1 parent f7d75d6 commit cad89af
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/LogWeaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ class LogWeaver implements Arrayable, Jsonable

private ?array $relation = null;

private ?bool $validate = true;

public function validate(?bool $validate): static
{
$this->validate = $validate;

return $this;
}

public function getValidate(): ?bool
{
return $this->validate;
}

public function getDescription(): string
{
return $this->description;
Expand Down Expand Up @@ -113,6 +127,10 @@ public function getLevel(): string

private function validateParameters(): void
{
if (! $this->getValidate()) {
return;
}

$data = [
'disk' => $this->getDisk(),
'directory' => $this->getDirectory(),
Expand All @@ -128,7 +146,7 @@ private function validateParameters(): void
'log_resource' => ['required', 'in:system,event'],
'description' => ['required', 'string'],
'directory' => ['string'],
'disk' => ['string', 'in:s3,local,ftp,sftp'],
'disk' => ['string', 'in:s3,local,ftp,sftp,public'],
'content' => ['required', 'array'],
];

Expand All @@ -154,6 +172,7 @@ private function getValidatedData(): array
'description' => $this->getDescription(),
'content' => $this->getContent(),
'relation' => $this->getRelation(),
'validate' => $this->getValidate(),
];
}

Expand Down

0 comments on commit cad89af

Please sign in to comment.