url: protocol required
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user