package p.packer.dtos;

import p.packer.messages.assets.PackerCodecConfigurationFieldType;

import java.util.List;
import java.util.Objects;

public record PackerCodecConfigurationFieldDTO(
        String key,
        String label,
        PackerCodecConfigurationFieldType fieldType,
        String value,
        boolean required,
        List<String> options) {

    public PackerCodecConfigurationFieldDTO {
        key = Objects.requireNonNull(key, "key").trim();
        label = Objects.requireNonNull(label, "label").trim();
        Objects.requireNonNull(fieldType, "fieldType");
        value = Objects.requireNonNullElse(value, "").trim();
        options = List.copyOf(Objects.requireNonNull(options, "options"));
        if (key.isBlank() || label.isBlank()) {
            throw new IllegalArgumentException("codec configuration field key and label must not be blank");
        }
    }
}
