# Path: ipuz/exceptions.py
# class IPUZException(Exception):
#     pass
# 
# Path: ipuz/structures/common.py
# def validate_cells(field_data):
#     if not isinstance(field_data, list) or not field_data:
#         return False
#     for element in field_data:
#         if (not isinstance(element, list) or
#                 len(element) != 2 or
#                 not all(type(e) is int for e in element)):
#             return False
#     return True
# 
# def validate_rect(field_data):
#     if not isinstance(field_data, list):
#         return False
#     if len(field_data) != 4 or not all(type(c) is int for c in field_data):
#         return False
#     if field_data[0] > field_data[2] or field_data[1] > field_data[3]:
#         return False
#     return True
# 
# Path: ipuz/structures/stylespec.py
# def validate_stylespec_value(value):
#     try:
#         validate_stylespec(value)
#     except IPUZException:
#         return False
#     return True
# 
# Path: ipuz/validators.py
# def validate_dict(field_data, validators):
#     if not isinstance(field_data, dict) or not field_data:
#         return False
#     for key, value in field_data.items():
#         if key not in validators:
#             return False
#         if not validators[key](value):
#             return False
#     return True
# 
# def validate_string(field_name, field_data):
#     if not isinstance(field_data, str):
#         raise IPUZException("Invalid {} value found".format(field_name))


from ipuz.exceptions import IPUZException
from .common import (
    validate_cells,
    validate_rect,
)
from .stylespec import validate_stylespec_value
from ipuz.validators import validate_dict, validate_string


def validate_groupspec(field_data):
    return validate_dict(field_data, {
        "rect": validate_rect,
        "cells": validate_cells,
        "style": validate_stylespec_value,
    })


def validate_groupspec_dict(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)
        if not key:

# Path: ipuz/exceptions.py
# class IPUZException(Exception):
#     pass
# 
# Path: ipuz/structures/common.py
# def validate_cells(field_data):
#     if not isinstance(field_data, list) or not field_data:
#         return False
#     for element in field_data:
#         if (not isinstance(element, list) or
#                 len(element) != 2 or
#                 not all(type(e) is int for e in element)):
#             return False
#     return True
# 
# def validate_rect(field_data):
#     if not isinstance(field_data, list):
#         return False
#     if len(field_data) != 4 or not all(type(c) is int for c in field_data):
#         return False
#     if field_data[0] > field_data[2] or field_data[1] > field_data[3]:
#         return False
#     return True
# 
# Path: ipuz/structures/stylespec.py
# def validate_stylespec_value(value):
#     try:
#         validate_stylespec(value)
#     except IPUZException:
#         return False
#     return True
# 
# Path: ipuz/validators.py
# def validate_dict(field_data, validators):
#     if not isinstance(field_data, dict) or not field_data:
#         return False
#     for key, value in field_data.items():
#         if key not in validators:
#             return False
#         if not validators[key](value):
#             return False
#     return True
# 
# def validate_string(field_name, field_data):
#     if not isinstance(field_data, str):
#         raise IPUZException("Invalid {} value found".format(field_name))


# Path: ipuz/structures/groupspec.py
from ipuz.exceptions import IPUZException
from .common import (
    validate_cells,
    validate_rect,
)
from .stylespec import validate_stylespec_value
from ipuz.validators import validate_dict, validate_string



def validate_groupspec(field_data):
    return validate_dict(field_data, {
        "rect": validate_rect,
        "cells": validate_cells,
        "style": validate_stylespec_value,
    })


def validate_groupspec_dict(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)
        if not key:

            raise IPUZException("Invalid {} value found".format(field_name))