DevShed has posted the final part of their look at using polymorphism with objects in PHP5, this time with a focus on validating incoming data from a form.
In this final installment of the series I'm going to show you how to develop an expandable PHP mechanism for validating different types of incoming data. This will demonstrate how this important pillar of object-oriented programming can be used with a plethora of applications.
They show how to create a simple DataValidator class to act as a base to build from. On top of this, they create classes to validate if the value is:
- empty
- an integer
- if it's numeric
- if it's in a certain range
- if it's alphanumeric
- if it's alphabetic
- or if it's a valid email address