url: protocol required

This commit is contained in:
Yurii
2026-03-04 14:05:48 +02:00
parent 6fa1ff811b
commit 0fbfe21258
5 changed files with 65 additions and 19 deletions
@@ -30,19 +30,17 @@
namespace Espo\Classes\FieldValidators;
use Espo\Core\Utils\Metadata;
use Espo\ORM\Defs;
use Espo\ORM\Entity;
class UrlType
{
private Metadata $metadata;
private VarcharType $varcharType;
public function __construct(Metadata $metadata, VarcharType $varcharType)
{
$this->metadata = $metadata;
$this->varcharType = $varcharType;
}
public function __construct(
private Metadata $metadata,
private VarcharType $varcharType,
private Defs $defs,
) {}
public function checkRequired(Entity $entity, string $field): bool
{
@@ -62,6 +60,15 @@ class UrlType
return true;
}
if (
$this->defs
->getEntity($entity->getEntityType())
->tryGetField($field)
?->getParam('protocolRequired')
) {
return filter_var($value, FILTER_VALIDATE_URL) !== false;
}
/** @var string $pattern */
$pattern = $this->metadata->get(['app', 'regExpPatterns', 'uriOptionalProtocol', 'pattern']);
@@ -245,7 +245,8 @@
"notStorable": "Not Storable",
"itemsEditable": "Items Editable",
"openInNewTab": "Open in new tab",
"notLockable": "Not Lockable"
"notLockable": "Not Lockable",
"protocolRequired": "Protocol Required"
},
"strings" : {
"rebuildRequired": "Rebuild is required"
@@ -18,6 +18,10 @@
"type": "bool",
"tooltip": "urlStrip"
},
{
"name": "protocolRequired",
"type": "bool"
},
{
"name": "copyToClipboard",
"type": "bool",