def validate(value, row):
    if not value:
        if halt_on_error:
            raise DataError('Missing RECTYPE in data demographic_id: %' % row['id'])
        else:
            log.write('rectype', [row['id'], row['rapstatex'], '', 'Missing RECTYPE in data.'])
            return 9
        
    elif value != '6':
        if halt_on_error:
            raise DataError('Wrong value for demographic RECTYPE (6), value = %s on demographic_id: %s' % (value, row['id']))
        else:
            log.write('rectype', [row['id'], row['rapstatex'], value, 
                                  "Wrong value for demographic RECTYPE (6)."])
    
    return value