Valid is correct, as a non valid product code won't help the system to determine a price. It's essential so I would use the valid. The product code textbox should only get focus, when it's time to enter a product code, though. That's surely the first step of serving a customer, but the system can't know how many items are purchased, so ou should only set focus to a control with code in valid when you're sure another product code is necessary.
The usual solution using a barcode scanner is programming a prefix the scanner sends before the barcode, the prefix will set focus to the product code textbox. That way you can almost be sure you get into the box and out again just shortly after the barcode is recognized. It only fails when the barcode can't be read, but most scanners then also won't send the prefix. Or if the barcode isn't in the data, that could lead to an invalid state sticking in the barcode box.
You can always allow an exitcode like all zeros or empty to be valid, resulting in the follow up logic NOT firing, as there is no product, price, so also no quantity or other things related to this receipt position. I'd not program the POS to ever just be in such a textbox for sake of doing anything else in the system between serving customers, like inserting a new product, defining discounts or whatever else is done with the system. The product code textbox could be made to only accept focus in the when, if it detects the hotkey that needs to be used to focus the textbox and so manually entering this "trap" you can only exit with a valid product code is made harder and you don't accidentally get trapped there. Besides an empty or 0 code letting you out again. It's overall feasible to do and gives control over the workflow, so I would still support the idea despite what Mike interprets.
I think you want to enforce a valid product code at some point in the process. It doesn't make sense to continue with an unknown product, unless you don't care about keeping stock and accept the cahier to simply enter the price for an unknown item and continue. But that could still be done with the idea of the exit code you allow as product code for "unknown product", maybe another code like 1 instead of empty or 0. And then you don't fall back to awaiting a valid product code but allow the cashier to enter a price for the unknown product and continue.
Chriss