package cz.kamma.llamarunner;

import java.util.regex.Pattern;

/**
 * Validation utilities for profile names.
 */
public class ProfileValidator {

    private static final int MAX_NAME_LENGTH = 100;
    private static final Pattern VALID_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_-]+$");

    /**
     * Validates a profile name.
     *
     * @param name the profile name to validate
     * @return error message if invalid, null if valid
     */
    public static String validateProfileName(String name) {
        if (name == null || name.trim().isEmpty()) {
            return "Profile name cannot be empty";
        }

        String trimmedName = name.trim();

        if (trimmedName.length() > MAX_NAME_LENGTH) {
            return "Profile name must be at most " + MAX_NAME_LENGTH + " characters";
        }

        if (!VALID_NAME_PATTERN.matcher(trimmedName).matches()) {
            return "Profile name can only contain letters, numbers, underscores, and hyphens";
        }

        return null;
    }

  }
