Json Schema transformer is done
Form builder stuck on infinite recurrsion
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user