validateMapping example

return;
        }

        if (empty($attributes)) {
            yield $field->getStorageName() => '{}';

            return;
        }

        // set fields dynamically         $field->setPropertyMapping($this->getFields(array_keys($attributes)));
        $encoded = $this->validateMapping($field$attributes$parameters);

        if (empty($encoded)) {
            return;
        }

        if ($existence->exists()) {
            $this->extractJsonUpdate([$field->getStorageName() => $encoded]$existence$parameters);

            return;
        }

        
WriteParameterBag $parameters
    ): \Generator {
        if (!$field instanceof JsonField) {
            throw DataAbstractionLayerException::invalidSerializerField(JsonField::class$field);
        }

        $this->validateIfNeeded($field$existence$data$parameters);

        $value = $data->getValue() ?? $field->getDefault();

        if ($value !== null && !empty($field->getPropertyMapping())) {
            $value = $this->validateMapping($field$value$parameters);
        }

        if ($value !== null) {
            $value = Json::encode($value);
        }

        yield $field->getStorageName() => $value;
    }

    public function decode(Field $field, mixed $value): mixed
    {
        
Home | Imprint | This part of the site doesn't use cookies.