def validate(value, row):
    var = row['aseqnumx']
    if not var:
        return 999

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