mirror of
https://code.castopod.org/adaures/castopod
synced 2025-04-23 01:01:20 +00:00

- add `.env.example` and `INSTALL.md` to castopod bundle for installation docs - update seeders to be silent on insert errors - update install layout - add manual config instructions when .env file is not writable - fix eslint error in Charts.ts module closes #32
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Validation;
|
|
|
|
class Rules
|
|
{
|
|
/**
|
|
* Value should not be within the array of protected slugs (adminGateway, authGateway or installGateway)
|
|
*
|
|
* @param string $value
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function not_in_protected_slugs(string $value = null): bool
|
|
{
|
|
$appConfig = config('App');
|
|
$protectedSlugs = [
|
|
$appConfig->adminGateway,
|
|
$appConfig->authGateway,
|
|
$appConfig->installGateway,
|
|
];
|
|
return !in_array($value, $protectedSlugs, true);
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
/**
|
|
* Checks a URL to ensure it's formed correctly.
|
|
*
|
|
* @param string $str
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function validate_url(string $str = null): bool
|
|
{
|
|
if (empty($str)) {
|
|
return false;
|
|
}
|
|
|
|
return filter_var($str, FILTER_VALIDATE_URL) !== false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
}
|