Validating address updating old furniture be still here
When it comes to parsing I generally prefer to return false rather than exceptions (the assumption being this is input that's not guaranteed to be correct).
Breaking the return statement down, I am saying, It does exactly what I assumed it did, however I was unaware that you could have the return at the bottom structured like that. For readability both in actual code and for this example, I ALWAYS chunk my regex pattern into a string array and then join it.
There are other ways to highlight the field in question besides changing the text color, the border color or the fill color could be changed instead, or in addition, just make sure that you are not making the form impossible to read. The client send me new order numbers that affect this file, I must change the 999 value and print the renewed file (I can have 70 different files and counting, waiting new orders numbers).
Another thing I like to do is to display the validation error message on the form in an otherwise hidden field: The problem with our last solution is that if the user saves a partially filled form, and picks it up at a later time, that error message that popped up is long gone, and the only indication that there is something wrong with the form is the modified field color.
So, having a text field contain that error message might be a good idea.
Let’s take a look at how to do that with a text field that is only supposed to have a value of either ‘AAAA’ or ‘BBBB’ (yes, I know that this does not make much sense in a real PDF form).
So, if the user enters ‘01234’ we should see an error message that would instruct the user about what type of data is valid for this field.
In that case, the previous value of the field is restored, and the user has to enter the data again.