in ml-tools-python/awspyml.py [0:0]
def validate(self):
"""Validates that the schema object is properly formed.
Either returns True or raises an exception.
Note this is not 100% robust and might not catch all
problems that the API will catch.
"""
if self.num_attributes() == 0:
raise InvalidSchemaException("no attributes defined")
for idx, var in enumerate(self.attributes()):
name = var["attributeName"]
typ = var["attributeType"]
if not name or not typ:
raise InvalidSchemaException(
"Variable #%d is not fully defined" % idx)
if len(name) > 64:
raise InvalidSchemaException("%s" % var["attributeName"])
if typ not in self.VALID_VARIABLE_TYPES:
raise InvalidSchemaException(
"variable %s has invalid type %s" % (name, typ))
return True # Passes all rules.