# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel


class RegexMatchAssertion(UncheckedBaseModel):
    """
    Regex match assertion.

    Checks if the actual value matches a regular expression pattern.

    Example:
        assertion = RegexMatchAssertion(
            type="regex_match",
            field_path="email",
            pattern=r"^[^@]+@[^@]+\.[^@]+$",
            description="Email should be valid format"
        )
    """

    type: typing.Literal["regex_match"] = "regex_match"
    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Human-readable description of this assertion
    """

    field_path: typing.Optional[str] = pydantic.Field(default=None)
    """
    JSON path to field (e.g., 'response.products[0].id'). If None, checks whole output.
    """

    pattern: str = pydantic.Field()
    """
    Regular expression pattern to match
    """

    case_sensitive: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether regex matching should be case-sensitive
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
