def validate(value, row):
    #TODO: create region which is an index for rapstate for faster parsing
    if not value:
        if halt_on_error:
            raise DataError('Missing RAPSTATE in data. supervision_id: %' % row['id'])
        else:
            log.write('rapstate', [row['id'], '', 'Error: RAPSTATE missing in data'])
    
    elif value.lower() not in regions:
        log.write('rapstate', [row['id'], '--', row['rapstatex'], 
                               "Warning: RAPSTATE in data not recognized."])
            
    return value