Added validateUrl optional flag for create/edit short URLs

This commit is contained in:
Alejandro Celaya
2020-09-23 19:19:17 +02:00
parent 1f78f5266a
commit d5eac3b1c3
11 changed files with 71 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core;
use Cake\Chronos\Chronos;
use DateTimeInterface;
use Fig\Http\Message\StatusCodeInterface;
use Laminas\InputFilter\InputFilter;
use PUGX\Shortid\Factory as ShortIdFactory;
use function sprintf;
@@ -62,3 +63,15 @@ function determineTableName(string $tableName, array $emConfig = []): string
return sprintf('%s.%s', $schema, $tableName);
}
function getOptionalIntFromInputFilter(InputFilter $inputFilter, string $fieldName): ?int
{
$value = $inputFilter->getValue($fieldName);
return $value !== null ? (int) $value : null;
}
function getOptionalBoolFromInputFilter(InputFilter $inputFilter, string $fieldName): ?bool
{
$value = $inputFilter->getValue($fieldName);
return $value !== null ? (bool) $value : null;
}