'Validates the schema.
This method checks if the schema itself is valid, and if the
default value - if present - complies to the schema\'s constraints.'

def validate(self, context=None):

    for c in self.constraints:
        if (not self._is_valid_constraint(c)):
            err_msg = (_('%(name)s    constraint    invalid    for    %(utype)s') % dict(name=type(c).__name__, utype=self.type))
            raise exception.InvalidSchemaError(message=err_msg)
    self._validate_default(context)
    if self.schema:
        if isinstance(self.schema, AnyIndexDict):
            self.schema.value.validate(context)
        else:
            for nested_schema in six.itervalues(self.schema):
                nested_schema.validate(context)
