Until now, our examples have been based around individual fields, such as an e-mail address or a website URL. The code is heavily duplicated, which makes for a bloated and inefficient solution.
Instead, let's completely flip our approach and turn our code into a generic plugin. We'll use the same core process to validate our code, depending on the regex that has been set within the plugin.
For this next exercise, we'll use a plugin produced by Cedric Ruiz. Although it is a few years old, it illustrates how we can create a single core validation process that uses a number of filters to verify the content entered in our form. Let's make a start by performing the following steps: