This commit is contained in:
2023-10-02 23:10:49 +03:00
commit c6cb488379
255 changed files with 18731 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace Lucent\Schema\Ui;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Validator\MinMaxInterface;
class Reference implements FieldInterface, MinMaxInterface
{
public FieldInfo $info;
/**
* @param string[] $collections
*/
public function __construct(
public string $name,
public string $label,
public string $mime = "",
public ?int $min = null,
public ?int $max = null,
public array $collections = [],
public string $layout = "",
public string $group = "",
)
{
$this->info = new FieldInfo("reference", "Reference", FieldType::REFERENCE);
}
public function format(array $input, array $output): array
{
return $output;
}
public function failMin(mixed $value): bool
{
if (is_null($value)) {
return false;
}
return count($value) < $this->min;
}
public function failMax(mixed $value): bool
{
if (is_null($value)) {
return false;
}
return count($value) < $this->min;
}
}