Json Schema transformer is done
Form builder stuck on infinite recurrsion
This commit is contained in:
@@ -2,12 +2,16 @@
|
||||
|
||||
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\MinMaxInterface;
|
||||
use Lucent\Schema\Validator\RequiredInterface;
|
||||
use PhpOption\Option;
|
||||
|
||||
class Number implements FieldInterface, RequiredInterface, MinMaxInterface
|
||||
{
|
||||
@@ -74,5 +78,29 @@ class Number implements FieldInterface, RequiredInterface, MinMaxInterface
|
||||
|
||||
return $value > $this->min;
|
||||
}
|
||||
|
||||
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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user