from django.core.validators import RegexValidator
from django.utils.translation import gettext_lazy as _

# Kubernetes resource name validator - follows the same rules as namespace names
kubernetes_name_validator = RegexValidator(
    regex=r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$",
    message=_(
        'Name must consist of lowercase alphanumeric characters or "-", '
        "must start and end with an alphanumeric character."
    ),
    code="invalid_kubernetes_name",
)
