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
+26
View File
@@ -2,11 +2,15 @@
namespace Lucent\Schema\Ui;
use Lucent\JsonSchema\Property\Property;
use Lucent\JsonSchema\Property\PropertyType;
use Lucent\JsonSchema\Property\TypeProperty;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Nullable;
use Lucent\Schema\Validator\RequiredInterface;
use PhpOption\Option;
class Textarea implements FieldInterface, RequiredInterface
{
@@ -41,5 +45,27 @@ class Textarea implements FieldInterface, RequiredInterface
return empty(trim($value));
}
public function isRequired(): bool
{
return $this->required;
}
public function toJsonSchema(): Property
{
return new TypeProperty(
type: PropertyType::STRING,
id: $this->name,
title: Option::fromValue($this->label),
description: Option::fromValue($this->help, ""),
default: Option::fromValue($this->default, ""),
minLength: Option::fromValue($this->min),
maxLength: Option::fromValue($this->max),
readOnly: Option::fromValue($this->readonly, false),
enum: none(),
comment: Option::fromValue($this->group, ""),
format: none(),
);
}
}