package com.r35157.nenjim.service.registry.valuetypes;

import org.jetbrains.annotations.NotNull;

/** Lookup identity assigned to one component registration in a Registry. */
public record NenjimComponentId(@NotNull String value) {
    public NenjimComponentId {
        value = value.strip();

        if (!value.matches(
                "[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*)*")) {
            throw new IllegalArgumentException(
                    "Invalid Nenjim component ID: '" + value + "'");
        }
    }
}
