package de.effigenix.domain.masterdata.customer;

import de.effigenix.shared.common.Result;

public record CustomerName(String value) {

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

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