package de.effigenix.domain.production;

import de.effigenix.shared.common.Result;

public record RecipeName(String value) {

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

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