Json Schema transformer is done

Form builder stuck on infinite recurrsion
This commit is contained in:
2024-03-14 22:12:26 +02:00
parent 584fe7eb95
commit 842bd71a18
30 changed files with 919 additions and 3 deletions
+24
View File
@@ -2,10 +2,15 @@
namespace Lucent\Schema\Ui;
use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\RefProperty;
use Lucent\JsonSchema\Property\RefType;
use Lucent\Primitive\Collection;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Validator\MinMaxInterface;
use PhpOption\Option;
class File implements FieldInterface, MinMaxInterface
{
@@ -52,5 +57,24 @@ class File implements FieldInterface, MinMaxInterface
return count($value) < $this->min;
}
public function toJsonSchema(): Property
{
return new RefProperty(
type: RefType::ANY_OF,
id: $this->name,
title: Option::fromValue($this->label),
description: Option::fromValue($this->help, ""),
_ref: new Collection($this->collections),
minItems: Option::fromValue($this->min),
maxItems: Option::fromValue($this->max),
comment: Option::fromValue($this->group, ""),
);
}
public function isRequired(): bool
{
return $this->min > 0;
}
}