1
0

IFilenameValidator.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Files;
  8. /**
  9. * @since 30.0.0
  10. */
  11. interface IFilenameValidator {
  12. /**
  13. * It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this
  14. * only checks if the filename is valid in general but not for a specific storage
  15. * which might have additional naming rules.
  16. *
  17. * @param string $filename The filename to check for validity
  18. * @return bool
  19. * @since 30.0.0
  20. */
  21. public function isFilenameValid(string $filename): bool;
  22. /**
  23. * It is recommended to use `\OCP\Files\Storage\IStorage::isFileValid` instead as this
  24. * only checks if the filename is valid in general but not for a specific storage
  25. * which might have additional naming rules.
  26. *
  27. * This will validate a filename and throw an exception with details on error.
  28. *
  29. * @param string $filename The filename to check for validity
  30. * @throws \OCP\Files\InvalidPathException or one of its child classes in case of an error
  31. * @since 30.0.0
  32. */
  33. public function validateFilename(string $filename): void;
  34. }