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