- WIP on validations

This commit is contained in:
Dev committed 2026-06-09 19:30:53 +00:00
1 parent c82eae5be4
commit f292ac63ca
5 files changed
+29 -6

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
<?php
namespace Lean\Api\Attribute;
enum CommonRegexFormatEnum : string
{
case BasicEmail = "/[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+/i";
}
+2 -2
View File
@@ -12,7 +12,7 @@ class ContextField
{
public function __construct(
public string $description = "",
public bool $mandatory = false,
public bool|MandatoryGroup $mandatory = false,
public ?int $minLength = null,
public ?int $maxLength = null,
public ?int $minValue = null,
@@ -25,7 +25,7 @@ class ContextField
public function assertValueSpecs(mixed $value, bool $isNew) : void
{
if ($isNew && ( $this->mandatory && $value === null )) {
if ($isNew && ( $this->mandatory === true && $value === null )) {
throw new MandatoryFieldException("Mandatory field must be provided a value.");
}
elseif ($value !== null) {
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Lean\Api\Attribute;
readonly class MandatoryGroup
{
public function __construct(
public string $name,
public int $needed = 1,
) {}
}