array validation max item length rename
This commit is contained in:
Generated
+5
@@ -6,6 +6,11 @@
|
||||
<option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
|
||||
<option name="FORCE_EMPTY_METHODS_IN_ONE_LINE" value="true" />
|
||||
</PHPCodeStyleSettings>
|
||||
<codeStyleSettings language="JSON">
|
||||
<indentOptions>
|
||||
<option name="INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
|
||||
|
||||
@@ -38,17 +38,10 @@ use stdClass;
|
||||
|
||||
class ArrayType
|
||||
{
|
||||
private Metadata $metadata;
|
||||
private const DEFAULT_MAX_ITEM_LENGTH = 100;
|
||||
|
||||
private Defs $defs;
|
||||
|
||||
private const DEFAULT_MAX_LENGTH = 100;
|
||||
|
||||
public function __construct(Metadata $metadata, Defs $defs)
|
||||
{
|
||||
$this->metadata = $metadata;
|
||||
$this->defs = $defs;
|
||||
}
|
||||
public function __construct(private Metadata $metadata, private Defs $defs)
|
||||
{}
|
||||
|
||||
public function checkRequired(Entity $entity, string $field): bool
|
||||
{
|
||||
@@ -181,9 +174,9 @@ class ArrayType
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkMaxLength(Entity $entity, string $field, ?int $validationValue): bool
|
||||
public function checkMaxItemLength(Entity $entity, string $field, ?int $validationValue): bool
|
||||
{
|
||||
$maxLength = $validationValue ?? self::DEFAULT_MAX_LENGTH;
|
||||
$maxLength = $validationValue ?? self::DEFAULT_MAX_ITEM_LENGTH;
|
||||
|
||||
/** @var string[] $value */
|
||||
$value = $entity->get($field) ?? [];
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
"valid",
|
||||
"required",
|
||||
"maxCount",
|
||||
"maxLength",
|
||||
"maxItemLength",
|
||||
"pattern",
|
||||
"noEmptyString"
|
||||
],
|
||||
@@ -71,7 +71,7 @@
|
||||
"array",
|
||||
"arrayOfString",
|
||||
"valid",
|
||||
"maxLength"
|
||||
"maxItemLength"
|
||||
],
|
||||
"filter": true,
|
||||
"notCreatable": false,
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
"valid",
|
||||
"required",
|
||||
"maxCount",
|
||||
"maxLength",
|
||||
"maxItemLength",
|
||||
"pattern",
|
||||
"noEmptyString"
|
||||
],
|
||||
@@ -78,7 +78,7 @@
|
||||
"array",
|
||||
"arrayOfString",
|
||||
"valid",
|
||||
"maxLength",
|
||||
"maxItemLength",
|
||||
"noEmptyString"
|
||||
],
|
||||
"filter": true,
|
||||
|
||||
Reference in New Issue
Block a user