import jsonschema


def validate_data(data, cls):
    """Validate data against the data and json schemas of an object class.

    Parameters
    ----------
    data : dict
        The data representation of an object.
    cls : :class:`compas.data.Data`
        The class of a data object.

    Returns
    -------
    dict
        The validated data.

    Raises
    ------
    SchemaError
    """
    jsonschema.validate(data, schema=cls.JSONSCHEMA)
    return cls.DATASCHEMA.validate(data)