Beispiel #1
0
def attribute_schema(name, meta):
    """ Validate the representation of a schema attribute. """
    schema = mapping(name,
                     validator=chained(
                         name_wrap(nonempty_string, name),
                         name_wrap(reserved_name(INVALID_NAMES), name),
                         name_wrap(database_name, name)))
    schema.add(key('label', validator=nonempty_string))
    schema.add(key('missing', missing=None))
    schema.add(
        key('type',
            validator=chained(nonempty_string, in_(ATTRIBUTE_TYPES_DB))))
    return schema
Beispiel #2
0
def attribute_schema(name, meta):
    """ Validate the representation of a schema attribute. """
    schema = mapping(name, validator=chained(
        name_wrap(nonempty_string, name),
        name_wrap(reserved_name(INVALID_NAMES), name),
        name_wrap(database_name, name)
        ))
    schema.add(key('label', validator=nonempty_string))
    schema.add(key('missing', missing=None))
    schema.add(key('type', validator=chained(
            nonempty_string,
            in_(ATTRIBUTE_TYPES_DB)
        )))
    return schema
Beispiel #3
0
def validate_schema(data):
    """ Validate a schema. This does not actually apply the
    schema to user data but checks for the integrity of its
    specification. """
    schema = mapping('schema')
    schema.add(
        key('name',
            validator=chained(
                nonempty_string,
                reserved_name(INVALID_NAMES),
                database_name,
            )))
    schema.add(key('label', validator=chained(nonempty_string, )))
    attributes = mapping('attributes')
    for attribute, meta in data.get('attributes', {}).items():
        attributes.add(attribute_schema(attribute, meta))
    schema.add(attributes)
    return schema.deserialize(data)
Beispiel #4
0
def validate_schema(data):
    """ Validate a schema. This does not actually apply the
    schema to user data but checks for the integrity of its
    specification. """
    schema = mapping('schema')
    schema.add(key('name', validator=chained(
            nonempty_string,
            reserved_name(INVALID_NAMES),
            database_name,
        )))
    schema.add(key('label', validator=chained(
            nonempty_string,
        )))
    attributes = mapping('attributes')
    for attribute, meta in data.get('attributes', {}).items():
        attributes.add(attribute_schema(attribute, meta))
    schema.add(attributes)
    return schema.deserialize(data)