dispatch/api/validators.py
def AuthorValidator(data):
    """Raise a ValidationError if data does not match the author format."""
    if not isinstance(data, list):
        # Convert single instance to a list
        data = [data]

    for author in data:
        if 'person' not in author:
            raise ValidationError('An author must contain a person.')
        if 'type' in author and not isinstance(author['type'], basestring):
            # If type is defined, it should be a string
            raise ValidationError('The author type must be a string.')
def AuthorValidator(data):
    """Raise a ValidationError if data does not match the author format."""
    if not isinstance(data, list):
        # Convert single instance to a list
        data = [data]

    for author in data:
        if 'person' not in author:
            raise ValidationError('An author must contain a person.')
        if 'type' in author and not isinstance(author['type'], basestring):
            # If type is defined, it should be a string
            raise ValidationError('The author type must be a string.')
def AuthorValidator ( data ) : if not isinstance ( data , list ) : # Convert single instance to a list data = [ data ] for author in data : if 'person' not in author : raise ValidationError ( 'An author must contain a person.' ) if 'type' in author and not isinstance ( author [ 'type' ] , basestring ) : # If type is defined, it should be a string raise ValidationError ( 'The author type must be a string.' )
Raise a ValidationError if data does not match the author format.
Raise a ValidationError if data does not match the author format .