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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel


class EditConditionalProperty(UncheckedBaseModel):
    """
    Field-level schema fragment used inside conditional clauses. These condition objects support nested JSON
    Schema structure such as `type`, `enum`, `items`, `properties`, `required`, and `contains`, but do not
    allow any `extend_edit:*` placement or styling keys.
    """

    type: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    JSON Schema type for the conditional property. Can be a simple type such as `"object"` or `"array"`,
    a nullable tuple like `["string", "null"]`, or omitted for enum-only constraints.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    Description of the field constraint.
    """

    enum: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Allowed values for enum-based conditional constraints.
    """

    items: typing.Optional["EditConditionalObjectProperty"] = pydantic.Field(default=None)
    """
    Nested array item schema for conditional array constraints.
    """

    properties: typing.Optional[typing.Dict[str, "EditConditionalProperty"]] = pydantic.Field(default=None)
    """
    Nested object property constraints.
    """

    required: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Required nested object properties.
    """

    additional_properties: typing_extensions.Annotated[
        typing.Optional[bool], FieldMetadata(alias="additionalProperties")
    ] = pydantic.Field(alias="additionalProperties", default=None)
    """
    Whether additional nested object properties are allowed.
    """

    const: typing.Optional[typing.Any] = pydantic.Field(default=None)
    """
    Exact value that the property must match.
    """

    pattern: typing.Optional[str] = pydantic.Field(default=None)
    """
    Regular expression that string values must match.
    """

    contains: typing.Optional["EditConditionalProperty"] = pydantic.Field(default=None)
    """
    Conditional schema that at least one array item must satisfy.
    """

    minimum: typing.Optional[float] = pydantic.Field(default=None)
    """
    Inclusive lower bound for numeric values.
    """

    maximum: typing.Optional[float] = pydantic.Field(default=None)
    """
    Inclusive upper bound for numeric values.
    """

    exclusive_minimum: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="exclusiveMinimum")] = (
        pydantic.Field(alias="exclusiveMinimum", default=None)
    )
    """
    Exclusive lower bound for numeric values.
    """

    exclusive_maximum: typing_extensions.Annotated[typing.Optional[float], FieldMetadata(alias="exclusiveMaximum")] = (
        pydantic.Field(alias="exclusiveMaximum", default=None)
    )
    """
    Exclusive upper bound for numeric values.
    """

    min_length: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minLength")] = pydantic.Field(
        alias="minLength", default=None
    )
    """
    Minimum string length.
    """

    max_length: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxLength")] = pydantic.Field(
        alias="maxLength", default=None
    )
    """
    Maximum string length.
    """

    min_items: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minItems")] = pydantic.Field(
        alias="minItems", default=None
    )
    """
    Minimum number of array items.
    """

    max_items: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxItems")] = pydantic.Field(
        alias="maxItems", default=None
    )
    """
    Maximum number of array items.
    """

    min_contains: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="minContains")] = (
        pydantic.Field(alias="minContains", default=None)
    )
    """
    Minimum number of matching items for `contains`.
    """

    max_contains: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="maxContains")] = (
        pydantic.Field(alias="maxContains", default=None)
    )
    """
    Maximum number of matching items for `contains`.
    """

    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


from .edit_conditional_object_property import EditConditionalObjectProperty  # noqa: E402, I001

update_forward_refs(EditConditionalProperty, EditConditionalObjectProperty=EditConditionalObjectProperty)
