from typing import Any, List, NamedTuple, Optional, Pattern

from coreschema.compat import numeric_types as numeric_types
from coreschema.compat import text_types as text_types
from coreschema.formats import validate_format as validate_format
from coreschema.utils import uniq as uniq

class Error(NamedTuple):
    text: str
    index: List[str]  # type: ignore [assignment]

def push_index(errors: List[Error], key: Any) -> List[str]: ...

class Schema:
    errors: List[Error] = ...
    title: Any = ...
    description: Any = ...
    default: Any = ...
    def __init__(self, title: str = ..., description: str = ..., default: Optional[Any] = ...) -> None: ...
    def make_error(self, code: str) -> Error: ...
    def __or__(self, other: Schema) -> Union: ...
    def __and__(self, other: Schema) -> Intersection: ...
    def __xor__(self, other: Schema) -> ExclusiveUnion: ...
    def __invert__(self) -> Not: ...
    def __eq__(self, other: Schema) -> bool: ...  # type: ignore [override]

class Object(Schema):
    errors: List[Error] = ...
    additional_properties_schema: Any = ...
    properties: Any = ...
    required: Optional[bool] = ...
    max_properties: int = ...
    min_properties: int = ...
    pattern_properties: Any = ...
    additional_properties: Any = ...
    pattern_properties_regex: Any = ...
    def __init__(
        self,
        properties: Optional[Any] = ...,
        required: Optional[bool] = ...,
        max_properties: Optional[Any] = ...,
        min_properties: Optional[Any] = ...,
        pattern_properties: Optional[Any] = ...,
        additional_properties: bool = ...,
        **kwargs: Any
    ) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Array(Schema):
    errors: List[Error] = ...
    items: Schema = ...
    max_items: int = ...
    min_items: int = ...
    unique_items: int = ...
    additional_items: int = ...
    def __init__(
        self,
        items: Optional[Any] = ...,
        max_items: Optional[Any] = ...,
        min_items: Optional[Any] = ...,
        unique_items: bool = ...,
        additional_items: bool = ...,
        **kwargs: Any
    ) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Number(Schema):
    integer_only: bool = ...
    errors: List[Error] = ...
    minimum: int = ...
    maximum: int = ...
    exclusive_minimum: int = ...
    exclusive_maximum: int = ...
    multiple_of: Optional[int] = ...
    def __init__(
        self,
        minimum: Optional[int] = ...,
        maximum: Optional[int] = ...,
        exclusive_minimum: bool = ...,
        exclusive_maximum: bool = ...,
        multiple_of: Optional[int] = ...,
        **kwargs: Any
    ) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Integer(Number):
    errors: List[Error] = ...
    integer_only: bool = ...

class String(Schema):
    errors: List[Error] = ...
    max_length: Any = ...
    min_length: Any = ...
    pattern: str = ...
    format: str = ...
    pattern_regex: Pattern[str] = ...
    def __init__(
        self,
        max_length: Optional[int] = ...,
        min_length: Optional[int] = ...,
        pattern: Optional[str] = ...,
        format: Optional[Any] = ...,
        **kwargs: Any
    ) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Boolean(Schema):
    errors: List[Error] = ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Null(Schema):
    errors: List[Error] = ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Enum(Schema):
    errors: List[Error] = ...
    enum: Any = ...
    exact: Any = ...
    def __init__(self, enum: Any, **kwargs: Any) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Anything(Schema):
    errors: List[Error] = ...
    types: Any = ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Union(Schema):
    errors: List[Error] = ...
    children: List[Schema] = ...
    def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Intersection(Schema):
    children: List[Schema] = ...
    def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class ExclusiveUnion(Schema):
    errors: List[Error] = ...
    children: List[Schema] = ...
    def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Not(Schema):
    errors: List[Error] = ...
    child: Any = ...
    def __init__(self, child: Any, **kwargs: Any) -> None: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class Ref(Schema):
    ref_name: Any = ...
    def __init__(self, ref_name: Any) -> None: ...
    def dereference(self, context: Any) -> Any: ...
    def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...

class RefSpace(Schema):
    refs: Any = ...
    root: Any = ...
    root_validator: Any = ...
    def __init__(self, refs: Any, root: Any) -> None: ...
    def validate(self, value: Any) -> List[Error]: ...
