Skip to content

Commit

Permalink
API Update validation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 15, 2024
1 parent df82059 commit c28b13f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ public function getAbsoluteSize()
public function validate()
{
$result = ValidationResult::create();
$this->File->validate($result, $this->Name);
$this->File->validateFilename($result, $this->Name);
$this->extend('updateValidate', $result);
return $result;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Storage/DBFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,18 @@ protected function isValidFilename(string $filename): bool
protected function assertFilenameValid(string $filename): void
{
$result = new ValidationResult();
$this->validate($result, $filename);
$this->validateFilename($result, $filename);
if (!$result->isValid()) {
throw new ValidationException($result);
}
}


/**
* Hook to validate this record against a validation result
*
* @param null|string $filename Optional filename to validate. If omitted, the current value is validated.
*/
public function validate(ValidationResult $result, ?string $filename = null): bool
public function validateFilename(ValidationResult $result, ?string $filename = null): bool
{
if (empty($filename)) {
$filename = $this->getFilename();
Expand Down Expand Up @@ -494,7 +493,6 @@ public function setField(string $fieldName, mixed $value, bool $markChanged = tr
return parent::setField($fieldName, $value, $markChanged);
}


/**
* Returns the size of the file type in an appropriate format.
*
Expand Down

0 comments on commit c28b13f

Please sign in to comment.