def validate(value, row):
    var = row['cycnumx']
    
    if not var:
        if halt_on_error:
            raise FatalDataError('Missing CYCNUMX in data @ arrest_id = %s' % row['id'])
        else:
            log.write('ccycnum', [row['id'], var, 'FatalError: Missing CYCNUM'])
        
        return 999

    if len(var) > 3:
        log.write('ccycnum', [row['id'], var, 'CYCNUM length gt 3. Truncating'])
    
    try:
        return int(var[:3])
    except ValueError:
        log.write('ccycnum', [row['id'], var, 'Invalid cycnum (string)'])
        return 999