Improve backward compatibility with legacy |@| encoding

This commit is contained in:
Kijin Sung 2024-10-09 00:34:20 +09:00
parent 460736c04d
commit d0f0d7205d

View file

@ -236,8 +236,22 @@ class Value
*/ */
public function validate($value): ?BaseObject public function validate($value): ?BaseObject
{ {
$is_array = is_array($value); // Take legacy encoding into consideration.
$values = is_array($value) ? $value : [$value]; if (is_array($value))
{
$is_array = true;
$values = $value;
}
elseif (str_contains($value, '|@|'))
{
$is_array = true;
$values = explode('|@|', $value);
}
else
{
$is_array = false;
$values = [$value];
}
// Check if a required value is empty. // Check if a required value is empty.
if ($this->is_required === 'Y') if ($this->is_required === 'Y')
@ -355,10 +369,12 @@ class Value
{ {
$values = explode('|@|', $value); $values = explode('|@|', $value);
} }
/*
elseif (str_contains($value, ',') && $type !== 'kr_zip') elseif (str_contains($value, ',') && $type !== 'kr_zip')
{ {
$values = explode(',', $value); $values = explode(',', $value);
} }
*/
else else
{ {
$values = [$value]; $values = [$value];