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

import typing

import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .v_2_bad_request_error_detail import V2BadRequestErrorDetail


class V2BadRequestError(UniversalBaseModel):
    """
    Bad request error response (HTTP 400) returned when request validation fails. Follows RFC 7807 Problem Details format with additional Payabli-specific fields.
    """

    type: str = pydantic.Field()
    """
    A URI reference that identifies the problem type. Points to human-readable documentation for this error type.
    """

    title: str = pydantic.Field()
    """
    Always "Bad Request" for 400 errors.
    """

    status: int = pydantic.Field()
    """
    HTTP status code, always 400 for bad requests.
    """

    detail: str = pydantic.Field()
    """
    Short description of the error.
    """

    instance: str = pydantic.Field()
    """
    Request URL that caused the error.
    """

    code: str = pydantic.Field()
    """
    Payabli's unified response code for validation errors. Starts with 'E'. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
    """

    errors: typing.Dict[str, typing.List[V2BadRequestErrorDetail]] = pydantic.Field()
    """
    Dictionary of field-specific validation errors. Keys are field paths (e.g., "paymentMethod.cardnumber") and values are arrays of error details.
    """

    token: typing.Optional[str] = pydantic.Field(default=None)
    """
    Pagination token (equivalent to pageIdentifier in v1 APIs). Usually null for errors.
    """

    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
