# Path: ipuz/structures/clue.py
# def validate_clues(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for direction, clues in field_data.items():
#         if not validate_direction(direction) or not isinstance(clues, list):
#             raise IPUZException("Invalid {} value found".format(field_name))
#         for clue in clues:
#             if not validate_clue(clue):
#                 raise IPUZException(
#                     "Invalid Clue in {} element found".format(field_name)
#                 )
# 
# Path: ipuz/structures/common.py
# def validate_dimensions(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for key, value in field_data.items():
#         if key not in ("width", "height"):
#             raise IPUZException("Invalid {} value found".format(field_name))
#     for key in ["width", "height"]:
#         if key not in field_data:
#             raise IPUZException(
#                 "Mandatory field {} of dimensions is missing".format(key)
#             )
#         if type(field_data[key]) is not int:
#             raise IPUZException(
#                 "Invalid {} value in dimensions field found".format(key)
#             )
#         if field_data[key] < 1:
#             raise IPUZException(
#                 "Field {} of dimensions is less than one".format(key)
#             )
# 
# Path: ipuz/structures/crosswordvalue.py
# def validate_crosswordvalues(field_name, field_data):
#     validate_list_of_lists(
#         field_name, field_data, "CrosswordValue", validate_crosswordvalue
#     )
# 
# Path: ipuz/structures/enumeration.py
# def validate_enumeration(field_data):
#     if not isinstance(field_data, str):
#         return False
#     return True
# 
# def validate_enumeration_field(field_name, field_data):
#     if not validate_enumeration(field_data):
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# Path: ipuz/structures/groupspec.py
# def validate_groupspec(field_data):
#     return validate_dict(field_data, {
#         "rect": validate_rect,
#         "cells": validate_cells,
#         "style": validate_stylespec_value,
#     })
# 
# Path: ipuz/structures/labeledcell.py
# def validate_labeledcell(field_data):
#     def validate_cell(cell):
#         if (cell is not None and
#                 type(cell) not in [int, dict] and
#                 not isinstance(cell, str)):
#             return False
#         if isinstance(cell, dict) and not cell:
#             return False
#         return True
#     if not validate_cell(field_data):
#         return False
#     if isinstance(field_data, dict):
#         if not all(key in ("cell", "style", "value") for key in field_data):
#             return False
#         if ("cell" in field_data and
#                 (isinstance(field_data["cell"], dict) or
#                  not validate_cell(field_data["cell"]))):
#             return False
#         if ("value" in field_data and
#                 not isinstance(field_data["value"], str)):
#             return False
#         if "style" in field_data:
#             try:
#                 validate_stylespec(field_data["style"])
#             except IPUZException:
#                 return False
#     return True
# 
# Path: ipuz/validators.py
# def validate_bool(field_name, field_data):
#     if not isinstance(field_data, bool):
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# def validate_dict_of_strings(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for key, value in field_data.items():
#         validate_string(field_name, key)
#         validate_string(field_name, value)
# 
# def validate_elements(field_name, field_data, elements):
#     if field_data not in elements:
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# def validate_list(field_name, field_data, element_name, validate_element):
#     if not isinstance(field_data, list):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for element in field_data:
#         if not validate_element(element):
#             message = "Invalid {} in {} element found".format(
#                 element_name, field_name
#             )
#             raise IPUZException(message)
# 
# def validate_list_of_lists(
#     field_name, field_data, element_name, validate_element
# ):
#     if (not isinstance(field_data, list) or
#             any(not isinstance(e, list) for e in field_data)):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for line in field_data:
#         for element in line:
#             if not validate_element(element):
#                 message = "Invalid {} in {} element found".format(
#                     element_name, field_name
#                 )
#                 raise IPUZException(message)
# 
# def validate_list_of_strings(field_name, field_data):
#     if not isinstance(field_data, list):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for element in field_data:
#         validate_string(field_name, field_data)
# 
# def validate_string(field_name, field_data):
#     if not isinstance(field_data, str):
#         raise IPUZException("Invalid {} value found".format(field_name))


from ipuz.structures import (
    validate_clues,
    validate_crosswordvalues,
    validate_dimensions,
    validate_enumeration,
    validate_enumeration_field,
    validate_groupspec,
    validate_labeledcell,
)
from ipuz.validators import (
    validate_bool,
    validate_dict_of_strings,
    validate_elements,
    validate_list,
    validate_list_of_lists,
    validate_list_of_strings,
    validate_string,
)


IPUZ_CROSSWORD_VALIDATORS = {
    "dimensions": validate_dimensions,
    "puzzle": (validate_list_of_lists, "LabeledCell", validate_labeledcell),
    "saved": validate_crosswordvalues,

# Path: ipuz/structures/clue.py
# def validate_clues(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for direction, clues in field_data.items():
#         if not validate_direction(direction) or not isinstance(clues, list):
#             raise IPUZException("Invalid {} value found".format(field_name))
#         for clue in clues:
#             if not validate_clue(clue):
#                 raise IPUZException(
#                     "Invalid Clue in {} element found".format(field_name)
#                 )
# 
# Path: ipuz/structures/common.py
# def validate_dimensions(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for key, value in field_data.items():
#         if key not in ("width", "height"):
#             raise IPUZException("Invalid {} value found".format(field_name))
#     for key in ["width", "height"]:
#         if key not in field_data:
#             raise IPUZException(
#                 "Mandatory field {} of dimensions is missing".format(key)
#             )
#         if type(field_data[key]) is not int:
#             raise IPUZException(
#                 "Invalid {} value in dimensions field found".format(key)
#             )
#         if field_data[key] < 1:
#             raise IPUZException(
#                 "Field {} of dimensions is less than one".format(key)
#             )
# 
# Path: ipuz/structures/crosswordvalue.py
# def validate_crosswordvalues(field_name, field_data):
#     validate_list_of_lists(
#         field_name, field_data, "CrosswordValue", validate_crosswordvalue
#     )
# 
# Path: ipuz/structures/enumeration.py
# def validate_enumeration(field_data):
#     if not isinstance(field_data, str):
#         return False
#     return True
# 
# def validate_enumeration_field(field_name, field_data):
#     if not validate_enumeration(field_data):
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# Path: ipuz/structures/groupspec.py
# def validate_groupspec(field_data):
#     return validate_dict(field_data, {
#         "rect": validate_rect,
#         "cells": validate_cells,
#         "style": validate_stylespec_value,
#     })
# 
# Path: ipuz/structures/labeledcell.py
# def validate_labeledcell(field_data):
#     def validate_cell(cell):
#         if (cell is not None and
#                 type(cell) not in [int, dict] and
#                 not isinstance(cell, str)):
#             return False
#         if isinstance(cell, dict) and not cell:
#             return False
#         return True
#     if not validate_cell(field_data):
#         return False
#     if isinstance(field_data, dict):
#         if not all(key in ("cell", "style", "value") for key in field_data):
#             return False
#         if ("cell" in field_data and
#                 (isinstance(field_data["cell"], dict) or
#                  not validate_cell(field_data["cell"]))):
#             return False
#         if ("value" in field_data and
#                 not isinstance(field_data["value"], str)):
#             return False
#         if "style" in field_data:
#             try:
#                 validate_stylespec(field_data["style"])
#             except IPUZException:
#                 return False
#     return True
# 
# Path: ipuz/validators.py
# def validate_bool(field_name, field_data):
#     if not isinstance(field_data, bool):
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# def validate_dict_of_strings(field_name, field_data):
#     if not isinstance(field_data, dict):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for key, value in field_data.items():
#         validate_string(field_name, key)
#         validate_string(field_name, value)
# 
# def validate_elements(field_name, field_data, elements):
#     if field_data not in elements:
#         raise IPUZException("Invalid {} value found".format(field_name))
# 
# def validate_list(field_name, field_data, element_name, validate_element):
#     if not isinstance(field_data, list):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for element in field_data:
#         if not validate_element(element):
#             message = "Invalid {} in {} element found".format(
#                 element_name, field_name
#             )
#             raise IPUZException(message)
# 
# def validate_list_of_lists(
#     field_name, field_data, element_name, validate_element
# ):
#     if (not isinstance(field_data, list) or
#             any(not isinstance(e, list) for e in field_data)):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for line in field_data:
#         for element in line:
#             if not validate_element(element):
#                 message = "Invalid {} in {} element found".format(
#                     element_name, field_name
#                 )
#                 raise IPUZException(message)
# 
# def validate_list_of_strings(field_name, field_data):
#     if not isinstance(field_data, list):
#         raise IPUZException("Invalid {} value found".format(field_name))
#     for element in field_data:
#         validate_string(field_name, field_data)
# 
# def validate_string(field_name, field_data):
#     if not isinstance(field_data, str):
#         raise IPUZException("Invalid {} value found".format(field_name))


# Path: ipuz/puzzlekinds/crossword.py
from ipuz.structures import (
    validate_clues,
    validate_crosswordvalues,
    validate_dimensions,
    validate_enumeration,
    validate_enumeration_field,
    validate_groupspec,
    validate_labeledcell,
)
from ipuz.validators import (
    validate_bool,
    validate_dict_of_strings,
    validate_elements,
    validate_list,
    validate_list_of_lists,
    validate_list_of_strings,
    validate_string,
)



IPUZ_CROSSWORD_VALIDATORS = {
    "dimensions": validate_dimensions,
    "puzzle": (validate_list_of_lists, "LabeledCell", validate_labeledcell),
    "saved": validate_crosswordvalues,

    "solution": validate_crosswordvalues,