package de.effigenix.domain.inventory;

import de.effigenix.shared.common.Result;

public record StorageLocationName(String value) {

    public static Result<StorageLocationError, StorageLocationName> of(String value) {
        if (value == null || value.isBlank()) {
            return Result.failure(new StorageLocationError.InvalidName("Name must not be blank"));
        }
        if (value.length() > 100) {
            return Result.failure(new StorageLocationError.InvalidName("Name must not exceed 100 characters"));
        }
        return Result.success(new StorageLocationName(value.trim()));
    }
}
