validation
This commit is contained in:
@@ -10,7 +10,11 @@ class Field
|
||||
public string $name,
|
||||
public string $type,
|
||||
public string $schemaId,
|
||||
public string $help,
|
||||
public bool $translatable,
|
||||
public bool $required,
|
||||
public bool $readonly,
|
||||
public bool $hidden,
|
||||
public int $rank,
|
||||
public IFieldProp $props,
|
||||
) {}
|
||||
|
||||
@@ -5,15 +5,7 @@ class FieldProp
|
||||
public static function fromType(string $type): IFieldProp
|
||||
{
|
||||
return match ($type) {
|
||||
"text" => new TextFieldProp(
|
||||
required: false,
|
||||
readonly: false,
|
||||
hidden: false,
|
||||
min: 0,
|
||||
max: 0,
|
||||
help: "",
|
||||
default: "",
|
||||
),
|
||||
"text" => new TextFieldProp(min: 0, max: 0, default: ""),
|
||||
default => new InvalidFieldProp(),
|
||||
};
|
||||
}
|
||||
@@ -28,12 +20,8 @@ class FieldProp
|
||||
{
|
||||
return match ($type) {
|
||||
"text" => new TextFieldProp(
|
||||
required: $props["required"] ?? false,
|
||||
readonly: $props["readonly"] ?? false,
|
||||
hidden: $props["hidden"] ?? false,
|
||||
min: $props["min"] ?? 0,
|
||||
max: $props["max"] ?? 0,
|
||||
help: $props["help"] ?? "",
|
||||
default: $props["default"] ?? "",
|
||||
),
|
||||
default => new InvalidFieldProp(),
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
class TextFieldProp implements IFieldProp
|
||||
{
|
||||
public function __construct(
|
||||
public bool $required,
|
||||
public bool $readonly,
|
||||
public bool $hidden,
|
||||
public string $default,
|
||||
public int $min,
|
||||
public int $max,
|
||||
public string $help,
|
||||
) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user