package de.effigenix.domain.masterdata.supplier;

import de.effigenix.shared.common.Result;

public record SupplierName(String value) {

    public SupplierName {
        if (value == null || value.isBlank()) {
            throw new IllegalArgumentException("SupplierName must not be blank");
        }
        if (value.length() > 200) {
            throw new IllegalArgumentException("SupplierName must not exceed 200 characters");
        }
    }

    public static Result<String, SupplierName> of(String value) {
        try {
            return Result.success(new SupplierName(value));
        } catch (IllegalArgumentException e) {
            return Result.failure(e.getMessage());
        }
    }
}
