Add a method to validate a barcode.